Skip to content

Instantly share code, notes, and snippets.

@yajd
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save yajd/9848252 to your computer and use it in GitHub Desktop.

Select an option

Save yajd/9848252 to your computer and use it in GitHub Desktop.
trying to extend whole findbar
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
const self = {
name: 'MatchWord',
path: {
chrome: 'chrome://matchword/content/'
},
aData: 0,
};
const myServices = {};
var cssUri;
var cssUriRemove;
Cu.import('resource://gre/modules/Services.jsm');
Cu.import('resource://gre/modules/devtools/Console.jsm');
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
XPCOMUtils.defineLazyGetter(myServices, 'sss', function(){ return Cc['@mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService) });
function startup(aData, aReason) {
self.aData = aData;
console.log('aData',aData);
var css = '.findbar-container { -moz-binding:url("' + self.path.chrome + 'findbar.xml#matchword") }';
var cssEnc = encodeURIComponent(css);
var newURIParam = {
aURL: 'data:text/css,' + cssEnc,
aOriginCharset: null,
aBaseURI: null
}
cssUri = Services.io.newURI(newURIParam.aURL, newURIParam.aOriginCharset, newURIParam.aBaseURI);
myServices.sss.loadAndRegisterSheet(cssUri, myServices.sss.USER_SHEET);
var css = '.findbar-container { -moz-binding:url("' + self.path.chrome + 'findbar.xml#matchword_shutdown") }';
var cssEnc = encodeURIComponent(css);
var newURIParam = {
aURL: 'data:text/css,' + cssEnc,
aOriginCharset: null,
aBaseURI: null
}
cssUriRemove = Services.io.newURI(newURIParam.aURL, newURIParam.aOriginCharset, newURIParam.aBaseURI);
}
function shutdown(aData, aReason) {
if (aReason == APP_SHUTDOWN) return;
myServices.sss.unregisterSheet(cssUri, myServices.sss.USER_SHEET);
myServices.sss.loadAndRegisterSheet(cssUriRemove, myServices.sss.USER_SHEET);
}
function install() {}
function uninstall() {}
<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="matchword">
<content>
<children/>
<xul:toolbarbutton anonid="matchwordbtn" accesskey="w" class="tabbable" label="Match Word" tooltiptext="Match only whole words" oncommand="console.log('hi')" type="checkbox"/>
</content>
</binding>
<binding id="matchword_shutdown">
<content>
<children/>
</content>
</binding>
</bindings>
<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="matchword" extends="chrome://global/content/bindings/findbar.xml#findbar">
<content>
<children/>
<xul:toolbarbutton anonid="matchwordbtn" accesskey="w" class="tabbable" label="Match Word" tooltiptext="Match only whole words" oncommand="console.log('hi')" type="checkbox"/>
</content>
</binding>
</bindings>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment