]>
Commit | Line | Data |
---|---|---|
68f5ac65 | 1 | <?xml version="1.0"?> |
2 | <!-- Copyright (c) 2017 Haggai Nuchi | |
3 | Available for use under the MIT License: | |
4 | https://opensource.org/licenses/MIT | |
5 | --> | |
6 | ||
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"> | |
10 | <implementation> | |
11 | <constructor><![CDATA[ | |
12 | if(window.userChromeJsMod) return; | |
13 | window.userChromeJsMod = true; | |
14 | ||
15 | var chromeFiles = FileUtils.getDir("UChrm", []).directoryEntries; | |
16 | var xulFiles = []; | |
17 | var sss = Cc['@mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService); | |
18 | ||
19 | while(chromeFiles.hasMoreElements()) { | |
20 | var file = chromeFiles.getNext().QueryInterface(Ci.nsIFile); | |
21 | var fileURI = Services.io.newFileURI(file); | |
22 | ||
23 | if(file.isFile()) { | |
24 | if(/(^userChrome|\.uc)\.js$/i.test(file.leafName)) { | |
25 | Services.scriptloader.loadSubScriptWithOptions(fileURI.spec, {target: window, ignoreCache: true}); | |
26 | } | |
27 | else if(/(^userChrome|\.uc)\.xul$/i.test(file.leafName)) { | |
28 | xulFiles.push(fileURI.spec); | |
29 | } | |
30 | else if(/\.as\.css$/i.test(file.leafName)) { | |
31 | if(!sss.sheetRegistered(fileURI, sss.AGENT_SHEET)) | |
32 | sss.loadAndRegisterSheet(fileURI, sss.AGENT_SHEET); | |
33 | } | |
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); | |
37 | } | |
38 | } | |
39 | } | |
40 | ||
41 | setTimeout(function loadXUL() { | |
42 | if(xulFiles.length > 0) { | |
43 | document.loadOverlay(xulFiles.shift(), null); | |
44 | setTimeout(loadXUL, 5); | |
45 | } | |
46 | }, 0); | |
47 | ]]></constructor> | |
48 | </implementation> | |
49 | </binding> | |
50 | </bindings> |