Created
September 10, 2015 20:17
-
-
Save stevepeak/634a4afdcc30fd645a79 to your computer and use it in GitHub Desktop.
How to check window before pageMod runs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _meta = worker.window.document.querySelector('meta[property="og:site_name"]'); | |
if (worker.window.location.hostname === "bitbucket.org" || (_meta && _meta.attributes.content.value === 'GitHub')) { | |
var data = require('sdk/self').data, | |
pageMod = require('sdk/page-mod'), | |
prefs = require('sdk/simple-prefs').prefs; | |
pageMod.PageMod({ | |
include: '*', | |
contentScriptFile : [data.url('jquery-2.1.3.min.js'), | |
data.url('codecov.js') | |
], | |
contentStyleFile : [data.url('codecov.css') | |
], | |
contentScriptWhen : 'end', | |
onAttach: function(worker){ | |
worker.port.emit('preferences', prefs); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Goal is to only mod the page when on Bitbucket, Github and Github Enterprise
We have enterprise customers whom would like to utilize the Add-on preventing me from adding specific domains to the
include
.Thanks!