Skip to content

Instantly share code, notes, and snippets.

@stevepeak
Created September 10, 2015 20:17
Show Gist options
  • Select an option

  • Save stevepeak/634a4afdcc30fd645a79 to your computer and use it in GitHub Desktop.

Select an option

Save stevepeak/634a4afdcc30fd645a79 to your computer and use it in GitHub Desktop.
How to check window before pageMod runs
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);
}
});
}
@stevepeak
Copy link
Copy Markdown
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment