Last active
July 18, 2019 20:24
-
-
Save ChoGGi/c194980ee3fa723c69f9e11ad40cee79 to your computer and use it in GitHub Desktop.
This file contains 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
<?xml version="1.0"?> | |
<!-- Copyright (c) 2017 Haggai Nuchi | |
Available for use under the MIT License: | |
https://opensource.org/licenses/MIT | |
--> | |
<!-- modified by alice0775 2019/05/24 | |
69.0a1 Bug 1519577 Convert toolbarbutton to a custom element | |
--> | |
<!-- modified by alice0775 2019/05/22 | |
69.0a1 Bug 1534407 - Enable browser.xhtml by default | |
--> | |
<!-- modified by alice0775 2018/08/28 | |
fix: menu would not popup. | |
--> | |
<!-- modified by alice0775 2018/08/03 | |
wirking with Sub-Script/Overlay Loader v3.0.56mod | |
--> | |
<!-- modified by alice0775 2018/08/02 | |
removed unused line. | |
--> | |
<!-- Run userChrome.js | |
<bindings xmlns="http://www.mozilla.org/xbl"> | |
--> | |
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:xbl="http://www.mozilla.org/xbl"> | |
<binding id="js"> | |
<implementation> | |
<constructor><![CDATA[ | |
if(window.userChromeJsMod) return; | |
window.userChromeJsMod = true; | |
const file = Services.dirsvc.get('UChrm', Components.interfaces.nsIFile); | |
file.append('userChrome.js'); | |
const mFileURL = Services.io.getProtocolHandler('file') | |
.QueryInterface(Components.interfaces.nsIFileProtocolHandler) | |
.getURLSpecFromFile(file) + "?" + file.lastModifiedTime; | |
try { | |
Components.utils.import('resource://gre/modules/Services.jsm'); | |
let maybeneed = true | |
let enumerator = Services.wm.getEnumerator("navigator:browser"); | |
while(enumerator.hasMoreElements()) { | |
var win = enumerator.getNext(); | |
if(typeof win.userChrome_js == "object") { | |
maybeneed = false; | |
break; | |
} | |
} | |
if (maybeneed) { | |
new class { | |
constructor() { | |
Services.obs.addObserver(this, 'domwindowopened', false); | |
} | |
observe(aSubject, aTopic, aData) { | |
switch (aTopic) { | |
case 'domwindowopened': | |
aSubject.addEventListener('load', this, true); | |
break; | |
} | |
} | |
handleEvent(aEvent) { | |
if (!Services.appinfo.inSafeMode) { | |
const document = aEvent.originalTarget; | |
if (document.location | |
&& document.location.protocol === 'chrome:' | |
&& !(document.location.href == "chrome://browser/content/browser.xhtml") ) { | |
try { | |
console.log("chrome window opened") | |
Services.scriptloader.loadSubScript(mFileURL, document.defaultView, 'UTF-8'); | |
} catch (ex) { | |
//Components.utils.reportError(ex); | |
} | |
} | |
} | |
} | |
}(); | |
} | |
} catch (exception) { | |
displayError(exception); | |
} | |
if (!Services.appinfo.inSafeMode) { | |
try { | |
console.log("browser window opened") | |
Services.scriptloader.loadSubScript(mFileURL, document.defaultView, 'UTF-8'); | |
} catch (ex) { | |
Components.utils.reportError(ex); | |
} | |
} | |
]]></constructor> | |
</implementation> | |
</binding> | |
<binding id="basecontrol"> | |
<implementation implements="nsIDOMXULControlElement"> | |
<!-- public implementation --> | |
<property name="disabled" onset="if (val) this.setAttribute('disabled', 'true'); | |
else this.removeAttribute('disabled'); | |
return val;" | |
onget="return this.getAttribute('disabled') == 'true';"/> | |
<property name="tabIndex" onget="return parseInt(this.getAttribute('tabindex')) || 0" | |
onset="if (val) this.setAttribute('tabindex', val); | |
else this.removeAttribute('tabindex'); return val;"/> | |
</implementation> | |
</binding> | |
<binding id="basetext" extends="userChrome.xml#basecontrol"> | |
<implementation implements="nsIDOMXULLabeledControlElement"> | |
<!-- public implementation --> | |
<property name="label" onset="this.setAttribute('label',val); return val;" | |
onget="return this.getAttribute('label');"/> | |
<property name="crop" onset="this.setAttribute('crop',val); return val;" | |
onget="return this.getAttribute('crop');"/> | |
<property name="image" onset="this.setAttribute('image',val); return val;" | |
onget="return this.getAttribute('image');"/> | |
<property name="command" onset="this.setAttribute('command',val); return val;" | |
onget="return this.getAttribute('command');"/> | |
<property name="accessKey"> | |
<getter> | |
<![CDATA[ | |
return this.labelElement ? this.labelElement.accessKey : this.getAttribute("accesskey"); | |
]]> | |
</getter> | |
<setter> | |
<![CDATA[ | |
// Always store on the control | |
this.setAttribute("accesskey", val); | |
// If there is a label, change the accesskey on the labelElement | |
// if it's also set there | |
if (this.labelElement) { | |
this.labelElement.accessKey = val; | |
} | |
return val; | |
]]> | |
</setter> | |
</property> | |
<field name="labelElement"/> | |
</implementation> | |
</binding> | |
<binding id="control-item" extends="userChrome.xml#basetext"> | |
<implementation> | |
<property name="value" onset="this.setAttribute('value', val); return val;" | |
onget="return this.getAttribute('value');"/> | |
</implementation> | |
</binding> | |
<binding id="root-element"> | |
<implementation> | |
<field name="_lightweightTheme">null</field> | |
<constructor><![CDATA[ | |
if (this.hasAttribute("lightweightthemes")) { | |
let temp = {}; | |
Components.utils.import("resource://gre/modules/LightweightThemeConsumer.jsm", temp); | |
this._lightweightTheme = new temp.LightweightThemeConsumer(this.ownerDocument); | |
} | |
]]></constructor> | |
<destructor><![CDATA[ | |
if (this._lightweightTheme) { | |
this._lightweightTheme.destroy(); | |
this._lightweightTheme = null; | |
} | |
]]></destructor> | |
</implementation> | |
</binding> | |
<binding id="iframe" role="outerdoc"> | |
<implementation> | |
<property name="docShell" readonly="true"> | |
<getter><![CDATA[ | |
let frameLoader = this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader; | |
return frameLoader ? frameLoader.docShell : null; | |
]]></getter> | |
</property> | |
<property name="contentWindow" | |
readonly="true" | |
onget="return this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindow);"/> | |
<property name="webNavigation" | |
onget="return this.docShell.QueryInterface(Components.interfaces.nsIWebNavigation);" | |
readonly="true"/> | |
<property name="contentDocument" readonly="true" | |
onget="return this.webNavigation.document;"/> | |
</implementation> | |
</binding> | |
<binding id="image" role="xul:image"> | |
<implementation implements="nsIDOMXULImageElement"> | |
<property name="src" | |
onget="return this.getAttribute('src');" | |
onset="this.setAttribute('src',val); return val;"/> | |
</implementation> | |
</binding> | |
<binding id="deck"> | |
<implementation> | |
<property name="selectedIndex" | |
onget="return this.getAttribute('selectedIndex') || '0'"> | |
<setter> | |
<![CDATA[ | |
if (this.selectedIndex == val) | |
return val; | |
this.setAttribute("selectedIndex", val); | |
var event = document.createEvent("Events"); | |
event.initEvent("select", true, true); | |
this.dispatchEvent(event); | |
return val; | |
]]> | |
</setter> | |
</property> | |
<property name="selectedPanel"> | |
<getter> | |
<![CDATA[ | |
return this.childNodes[this.selectedIndex]; | |
]]> | |
</getter> | |
<setter> | |
<![CDATA[ | |
var selectedIndex = -1; | |
for (var panel = val; panel != null; panel = panel.previousSibling) | |
++selectedIndex; | |
this.selectedIndex = selectedIndex; | |
return val; | |
]]> | |
</setter> | |
</property> | |
</implementation> | |
</binding> | |
<!-- | |
<binding id="dropmarker" extends="xul:button" role="xul:dropmarker"> | |
<resources> | |
<stylesheet src="chrome://global/skin/dropmarker.css"/> | |
</resources> | |
<content> | |
<xul:image class="dropmarker-icon"/> | |
</content> | |
</binding> | |
--> | |
<binding id="windowdragbox"> | |
<implementation> | |
<field name="_dragBindingAlive">true</field> | |
<constructor> | |
if (!this._draggableStarted) { | |
this._draggableStarted = true; | |
try { | |
let tmp = {}; | |
Components.utils.import("resource://gre/modules/WindowDraggingUtils.jsm", tmp); | |
let draghandle = new tmp.WindowDraggingElement(this); | |
draghandle.mouseDownCheck = function() { | |
return this._dragBindingAlive; | |
}; | |
} catch (e) {} | |
} | |
</constructor> | |
</implementation> | |
</binding> | |
<binding id="menuitem-base" role="xul:menuitem" | |
extends="userChrome.xml#control-item"> | |
<resources> | |
<stylesheet src="chrome://global/skin/menu.css"/> | |
</resources> | |
<implementation implements="nsIDOMXULSelectControlItemElement, nsIDOMXULContainerItemElement"> | |
<!-- nsIDOMXULSelectControlItemElement --> | |
<property name="selected" readonly="true" | |
onget="return this.getAttribute('selected') == 'true';"/> | |
<property name="control" readonly="true"> | |
<getter> | |
<![CDATA[ | |
var parent = this.parentNode; | |
if (parent && | |
parent.parentNode instanceof Components.interfaces.nsIDOMXULSelectControlElement) | |
return parent.parentNode; | |
return null; | |
]]> | |
</getter> | |
</property> | |
<!-- nsIDOMXULContainerItemElement --> | |
<property name="parentContainer" readonly="true"> | |
<getter> | |
for (var parent = this.parentNode; parent; parent = parent.parentNode) { | |
if (parent instanceof Components.interfaces.nsIDOMXULContainerElement) | |
return parent; | |
} | |
return null; | |
</getter> | |
</property> | |
</implementation> | |
</binding> | |
<binding id="menu-base" | |
extends="userChrome.xml#menuitem-base"> | |
<implementation implements="nsIDOMXULContainerElement"> | |
<property name="open" onget="return this.hasAttribute('open');"> | |
<setter><![CDATA[ | |
this.boxObject.openMenu(val); | |
return val; | |
]]></setter> | |
</property> | |
<property name="openedWithKey" readonly="true"> | |
<getter><![CDATA[ | |
return this.boxObject.openedWithKey; | |
]]></getter> | |
</property> | |
<!-- nsIDOMXULContainerElement interface --> | |
<method name="appendItem"> | |
<parameter name="aLabel"/> | |
<parameter name="aValue"/> | |
<body> | |
return this.insertItemAt(-1, aLabel, aValue); | |
</body> | |
</method> | |
<method name="insertItemAt"> | |
<parameter name="aIndex"/> | |
<parameter name="aLabel"/> | |
<parameter name="aValue"/> | |
<body> | |
const XUL_NS = | |
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; | |
var menupopup = this.menupopup; | |
if (!menupopup) { | |
menupopup = this.ownerDocument.createElementNS(XUL_NS, "menupopup"); | |
this.appendChild(menupopup); | |
} | |
var menuitem = this.ownerDocument.createElementNS(XUL_NS, "menuitem"); | |
menuitem.setAttribute("label", aLabel); | |
menuitem.setAttribute("value", aValue); | |
var before = this.getItemAtIndex(aIndex); | |
if (before) | |
return menupopup.insertBefore(menuitem, before); | |
return menupopup.appendChild(menuitem); | |
</body> | |
</method> | |
<method name="removeItemAt"> | |
<parameter name="aIndex"/> | |
<body> | |
<![CDATA[ | |
var menupopup = this.menupopup; | |
if (menupopup) { | |
var item = this.getItemAtIndex(aIndex); | |
if (item) | |
return menupopup.removeChild(item); | |
} | |
return null; | |
]]> | |
</body> | |
</method> | |
<property name="itemCount" readonly="true"> | |
<getter> | |
var menupopup = this.menupopup; | |
return menupopup ? menupopup.childNodes.length : 0; | |
</getter> | |
</property> | |
<method name="getIndexOfItem"> | |
<parameter name="aItem"/> | |
<body> | |
<![CDATA[ | |
var menupopup = this.menupopup; | |
if (menupopup) { | |
var items = menupopup.childNodes; | |
var length = items.length; | |
for (var index = 0; index < length; ++index) { | |
if (items[index] == aItem) | |
return index; | |
} | |
} | |
return -1; | |
]]> | |
</body> | |
</method> | |
<method name="getItemAtIndex"> | |
<parameter name="aIndex"/> | |
<body> | |
<![CDATA[ | |
var menupopup = this.menupopup; | |
if (!menupopup || aIndex < 0 || aIndex >= menupopup.childNodes.length) | |
return null; | |
return menupopup.childNodes[aIndex]; | |
]]> | |
</body> | |
</method> | |
<property name="menupopup" readonly="true"> | |
<getter> | |
<![CDATA[ | |
const XUL_NS = | |
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; | |
for (var child = this.firstChild; child; child = child.nextSibling) { | |
if (child.namespaceURI == XUL_NS && child.localName == "menupopup") | |
return child; | |
} | |
return null; | |
]]> | |
</getter> | |
</property> | |
</implementation> | |
</binding> | |
<binding id="menu" | |
extends="userChrome.xml#menu-base"> | |
<content> | |
<xul:label class="menu-text" xbl:inherits="value=label,accesskey,crop" crop="right"/> | |
<xul:hbox class="menu-accel-container" anonid="accel"> | |
<xul:label class="menu-accel" xbl:inherits="value=acceltext"/> | |
</xul:hbox> | |
<xul:hbox align="center" class="menu-right" xbl:inherits="_moz-menuactive,disabled"> | |
<xul:image/> | |
</xul:hbox> | |
<children includes="menupopup"/> | |
</content> | |
</binding> | |
<binding id="menuitem" extends="userChrome.xml#menuitem-base"> | |
<content> | |
<xul:label class="menu-text" xbl:inherits="value=label,accesskey,crop" crop="right"/> | |
<xul:hbox class="menu-accel-container" anonid="accel"> | |
<xul:label class="menu-accel" xbl:inherits="value=acceltext"/> | |
</xul:hbox> | |
</content> | |
</binding> | |
<binding id="menucaption" extends="userChrome.xml#menu-base"> | |
<content> | |
<xul:label class="menu-text" xbl:inherits="value=label,crop" crop="right"/> | |
</content> | |
</binding> | |
<binding id="menu-menubar" | |
extends="userChrome.xml#menu-base"> | |
<content> | |
<xul:label class="menubar-text" xbl:inherits="value=label,accesskey,crop" crop="right"/> | |
<children includes="menupopup"/> | |
</content> | |
</binding> | |
<binding id="menu-menubar-iconic" | |
extends="userChrome.xml#menu-base"> | |
<content> | |
<xul:image class="menubar-left" xbl:inherits="src=image"/> | |
<xul:label class="menubar-text" xbl:inherits="value=label,accesskey,crop" crop="right"/> | |
<children includes="menupopup"/> | |
</content> | |
</binding> | |
<binding id="menuitem-iconic" extends="userChrome.xml#menuitem"> | |
<content> | |
<xul:hbox class="menu-iconic-left" align="center" pack="center" | |
xbl:inherits="selected,_moz-menuactive,disabled,checked"> | |
<xul:image class="menu-iconic-icon" xbl:inherits="src=image,validate,src"/> | |
</xul:hbox> | |
<xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/> | |
<children/> | |
<xul:hbox class="menu-accel-container" anonid="accel"> | |
<xul:label class="menu-iconic-accel" xbl:inherits="value=acceltext"/> | |
</xul:hbox> | |
</content> | |
</binding> | |
<binding id="menuitem-iconic-noaccel" extends="userChrome.xml#menuitem"> | |
<content> | |
<xul:hbox class="menu-iconic-left" align="center" pack="center" | |
xbl:inherits="selected,disabled,checked"> | |
<xul:image class="menu-iconic-icon" xbl:inherits="src=image,validate,src"/> | |
</xul:hbox> | |
<xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/> | |
</content> | |
</binding> | |
<binding id="menucaption-inmenulist" extends="userChrome.xml#menucaption"> | |
<content> | |
<xul:hbox class="menu-iconic-left" align="center" pack="center" | |
xbl:inherits="selected,disabled,checked"> | |
<xul:image class="menu-iconic-icon" xbl:inherits="src=image,validate,src"/> | |
</xul:hbox> | |
<xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,crop" crop="right"/> | |
</content> | |
</binding> | |
<binding id="menuitem-iconic-desc-noaccel" extends="userChrome.xml#menuitem"> | |
<content> | |
<xul:hbox class="menu-iconic-left" align="center" pack="center" | |
xbl:inherits="selected,disabled,checked"> | |
<xul:image class="menu-iconic-icon" xbl:inherits="src=image,validate,src"/> | |
</xul:hbox> | |
<xul:label class="menu-iconic-text" xbl:inherits="value=label,accesskey,crop" crop="right" flex="1"/> | |
<xul:label class="menu-iconic-text menu-description" xbl:inherits="value=description" crop="right" flex="10000"/> | |
</content> | |
</binding> | |
<binding id="menu-iconic" | |
extends="userChrome.xml#menu-base"> | |
<content> | |
<xul:hbox class="menu-iconic-left" align="center" pack="center"> | |
<xul:image class="menu-iconic-icon" xbl:inherits="src=image"/> | |
</xul:hbox> | |
<xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/> | |
<xul:hbox class="menu-accel-container" anonid="accel"> | |
<xul:label class="menu-iconic-accel" xbl:inherits="value=acceltext"/> | |
</xul:hbox> | |
<xul:hbox align="center" class="menu-right" xbl:inherits="_moz-menuactive,disabled"> | |
<xul:image/> | |
</xul:hbox> | |
<children includes="menupopup|template"/> | |
</content> | |
</binding> | |
<binding id="menubutton-item" extends="userChrome.xml#menuitem-base"> | |
<content> | |
<xul:label class="menubutton-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/> | |
<children includes="menupopup"/> | |
</content> | |
</binding> | |
<binding id="menuseparator" role="xul:menuseparator" | |
extends="userChrome.xml#menuitem-base"> | |
</binding> | |
</bindings> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment