2 <!-- Copyright (c) 2017 Haggai Nuchi
3 Available for use under the MIT License:
4 https://opensource.org/licenses/MIT
7 <!-- Run userChrome.js/userChrome.xul and .uc.js/.uc.xul/.css files -->
8 <bindings xmlns="http://www.mozilla.org/xbl">
9 <binding id="js" extends="chrome://global/content/bindings/toolbarbutton.xml#menu">
11 <constructor><![CDATA[
12 if(window.userChromeJsMod) return;
13 window.userChromeJsMod = true;
15 var chromeFiles = FileUtils.getDir("UChrm", []).directoryEntries;
17 var sss = Cc['@mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService);
19 while(chromeFiles.hasMoreElements()) {
20 var file = chromeFiles.getNext().QueryInterface(Ci.nsIFile);
21 var fileURI = Services.io.newFileURI(file);
24 if(/(^userChrome|\.uc)\.js$/i.test(file.leafName)) {
25 Services.scriptloader.loadSubScriptWithOptions(fileURI.spec, {target: window, ignoreCache: true});
27 else if(/(^userChrome|\.uc)\.xul$/i.test(file.leafName)) {
28 xulFiles.push(fileURI.spec);
30 else if(/\.as\.css$/i.test(file.leafName)) {
31 if(!sss.sheetRegistered(fileURI, sss.AGENT_SHEET))
32 sss.loadAndRegisterSheet(fileURI, sss.AGENT_SHEET);
34 else if(/^(?!(userChrome|userContent)\.css$).+\.css$/i.test(file.leafName)) {
35 if(!sss.sheetRegistered(fileURI, sss.USER_SHEET))
36 sss.loadAndRegisterSheet(fileURI, sss.USER_SHEET);
41 setTimeout(function loadXUL() {
42 if(xulFiles.length > 0) {
43 document.loadOverlay(xulFiles.shift(), null);
44 setTimeout(loadXUL, 5);