Skip to content

Commit

Permalink
3.1.9: Update several scripts.
Browse files Browse the repository at this point in the history
Add styles for the statusbar webrtc indicator.
Switch to tab-size 2 (refactor all CSS and JS files)
  • Loading branch information
aminomancer committed Jun 16, 2022
1 parent ce657ec commit 4011ad7
Show file tree
Hide file tree
Showing 132 changed files with 29,839 additions and 29,104 deletions.
150 changes: 74 additions & 76 deletions JS/aboutCfg.uc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,110 +10,108 @@

// user configuration
const config = {
// the value to put after "about:" — if this is "cfg" then the final URl will be "about:cfg". if
// you use this and my appMenuAboutConfigButton.uc.js script, and you want to change this
// address for whatever reason, be sure to edit the urlOverride setting in that script so it
// says "about:your-new-address"
address: "cfg",
// the value to put after "about:" — if this is "cfg" then the final URl will
// be "about:cfg". if you use this and my appMenuAboutConfigButton.uc.js
// script, and you want to change this address for whatever reason, be sure to
// edit the urlOverride setting in that script so it says
// "about:your-new-address"
address: "cfg",

// the script tries to automatically find earthlng's aboutconfig URL, e.g.
// "chrome://userchrome/content/aboutconfig/config.xhtml" if you followed the instructions on my
// repo for making it compatible with fx-autoconfig. alternatively, it should also be able to
// find the URL if you use earthlng's autoconfig loader or xiaoxiaoflood's, and didn't modify
// anything. if it's unable to find the URL for your particular setup, please find it yourself
// and paste it here, *inside the quotes*
pathOverride: "",
// the script tries to automatically find earthlng's aboutconfig URL, e.g.
// "chrome://userchrome/content/aboutconfig/config.xhtml" if you followed the
// instructions on my repo for making it compatible with fx-autoconfig.
// alternatively, it should also be able to find the URL if you use earthlng's
// autoconfig loader or xiaoxiaoflood's, and didn't modify anything. if it's
// unable to find the URL for your particular setup, please find it yourself
// and paste it here, *inside the quotes*
pathOverride: "",
};

let { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
let { classes: Cc, interfaces: Ci, manager: Cm, utils: Cu, results: Cr } = Components;
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);

function findAboutConfig() {
if (config.pathOverride) return config.pathOverride;
let dir = Services.dirsvc.get("UChrm", Ci.nsIFile);
let appendFn = (nm) => dir.append(nm);
if (config.pathOverride) return config.pathOverride;
let dir = Services.dirsvc.get("UChrm", Ci.nsIFile);
let appendFn = nm => dir.append(nm);

// fx-autoconfig
["resources", "aboutconfig", "config.xhtml"].forEach(appendFn);
if (dir.exists()) return "chrome://userchrome/content/aboutconfig/config.xhtml";
// fx-autoconfig
["resources", "aboutconfig", "config.xhtml"].forEach(appendFn);
if (dir.exists()) return "chrome://userchrome/content/aboutconfig/config.xhtml";

// earthlng's loader
dir = Services.dirsvc.get("UChrm", Ci.nsIFile);
["utils", "aboutconfig", "config.xhtml"].forEach(appendFn);
if (dir.exists()) return "chrome://userchromejs/content/aboutconfig/config.xhtml";
// earthlng's loader
dir = Services.dirsvc.get("UChrm", Ci.nsIFile);
["utils", "aboutconfig", "config.xhtml"].forEach(appendFn);
if (dir.exists()) return "chrome://userchromejs/content/aboutconfig/config.xhtml";

// xiaoxiaoflood's loader
dir = Services.dirsvc.get("UChrm", Ci.nsIFile);
["utils", "aboutconfig", "aboutconfig.xhtml"].forEach(appendFn);
if (dir.exists()) return "chrome://userchromejs/content/aboutconfig/aboutconfig.xhtml";
// xiaoxiaoflood's loader
dir = Services.dirsvc.get("UChrm", Ci.nsIFile);
["utils", "aboutconfig", "aboutconfig.xhtml"].forEach(appendFn);
if (dir.exists()) return "chrome://userchromejs/content/aboutconfig/aboutconfig.xhtml";

// no about:config replacement found
return false;
// no about:config replacement found
return false;
}

// generate a unique ID on every app launch. protection against the very unlikely possibility that a
// future update adds a component with the same class ID, which would break the script.
// generate a unique ID on every app launch. protection against the very
// unlikely possibility that a future update adds a component with the same
// class ID, which would break the script.
function generateFreeCID() {
let uuid = Components.ID(
Cc["@mozilla.org/uuid-generator;1"]
.getService(Ci.nsIUUIDGenerator)
.generateUUID()
.toString()
let uuid = Components.ID(
Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator).generateUUID().toString()
);
// I can't tell whether generateUUID is guaranteed to produce a unique ID, or
// just a random ID. so I add this loop to regenerate it in the extremely
// unlikely (or potentially impossible) event that the UUID is already
// registered as a CID.
while (registrar.isCIDRegistered(uuid)) {
uuid = Components.ID(
Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator).generateUUID().toString()
);
// I can't tell whether generateUUID is guaranteed to produce a unique ID, or just a random ID.
// so I add this loop to regenerate it in the extremely unlikely (or potentially impossible)
// event that the UUID is already registered as a CID.
while (registrar.isCIDRegistered(uuid)) {
uuid = Components.ID(
Cc["@mozilla.org/uuid-generator;1"]
.getService(Ci.nsIUUIDGenerator)
.generateUUID()
.toString()
);
}
return uuid;
}
return uuid;
}

function VintageAboutConfig() {}

let urlString = findAboutConfig();

VintageAboutConfig.prototype = {
get uri() {
if (!urlString) return null;
return this._uri || (this._uri = Services.io.newURI(urlString));
},
newChannel: function (_uri, loadInfo) {
const ch = Services.io.newChannelFromURIWithLoadInfo(this.uri, loadInfo);
ch.owner = Services.scriptSecurityManager.getSystemPrincipal();
return ch;
},
getURIFlags: function (_uri) {
return Ci.nsIAboutModule.ALLOW_SCRIPT | Ci.nsIAboutModule.IS_SECURE_CHROME_UI;
},
getChromeURI: function (_uri) {
return this.uri;
},
QueryInterface: ChromeUtils.generateQI(["nsIAboutModule"]),
get uri() {
if (!urlString) return null;
return this._uri || (this._uri = Services.io.newURI(urlString));
},
newChannel: function (_uri, loadInfo) {
const ch = Services.io.newChannelFromURIWithLoadInfo(this.uri, loadInfo);
ch.owner = Services.scriptSecurityManager.getSystemPrincipal();
return ch;
},
getURIFlags: function (_uri) {
return Ci.nsIAboutModule.ALLOW_SCRIPT | Ci.nsIAboutModule.IS_SECURE_CHROME_UI;
},
getChromeURI: function (_uri) {
return this.uri;
},
QueryInterface: ChromeUtils.generateQI(["nsIAboutModule"]),
};

var AboutModuleFactory = {
createInstance(aOuter, aIID) {
if (aOuter) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
return new VintageAboutConfig().QueryInterface(aIID);
},
QueryInterface: ChromeUtils.generateQI(["nsIFactory"]),
createInstance(aOuter, aIID) {
if (aOuter) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
return new VintageAboutConfig().QueryInterface(aIID);
},
QueryInterface: ChromeUtils.generateQI(["nsIFactory"]),
};

if (urlString)
registrar.registerFactory(
generateFreeCID(),
`about:${config.address}`,
`@mozilla.org/network/protocol/about;1?what=${config.address}`,
AboutModuleFactory
);
registrar.registerFactory(
generateFreeCID(),
`about:${config.address}`,
`@mozilla.org/network/protocol/about;1?what=${config.address}`,
AboutModuleFactory
);

let EXPORTED_SYMBOLS = [];
124 changes: 65 additions & 59 deletions JS/animateContextMenus.uc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,75 +3,81 @@
// @version 1.0.1
// @author aminomancer
// @homepage https://github.com/aminomancer/uc.css.js
// @description Give all context menus the same opening animation that panel popups like the app menu have — the menu slides down 70px and fades in opacity at the same time. It's a cool effect that doesn't trigger a reflow since it uses transform, but it does repaint the menu, so I wouldn't recommend using this on weak hardware.
// @description Give all context menus the same opening animation that panel
// popups like the app menu have — the menu slides down 70px and fades in
// opacity at the same time. It's a cool effect that doesn't trigger a reflow
// since it uses transform, but it does repaint the menu, so I wouldn't
// recommend using this on weak hardware.
// @license This Source Code Form is subject to the terms of the Creative Commons Attribution-NonCommercial-ShareAlike International License, v. 4.0. If a copy of the CC BY-NC-SA 4.0 was not distributed with this file, You can obtain one at http://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
// @include *
// ==/UserScript==

class AnimateContextMenus {
constructor() {
document.documentElement.setAttribute("animate-menupopups", true);
addEventListener("popupshowing", this);
addEventListener("popupshown", this);
addEventListener("popuphidden", this);
let css = `
:root[animate-menupopups] :not(menulist) > menupopup:not([position], [type="arrow"], [animate="false"]) {
opacity: 0;
transform: translateY(-70px) scaleX(0.95) scaleY(0.5);
transform-origin: top;
transition-property: transform, opacity;
transition-duration: 0.18s, 0.18s;
transition-timing-function:
var(--animation-easing-function, cubic-bezier(.07, .95, 0, 1)), ease-out;
transform-style: flat;
backface-visibility: hidden;
constructor() {
document.documentElement.setAttribute("animate-menupopups", true);
addEventListener("popupshowing", this);
addEventListener("popupshown", this);
addEventListener("popuphidden", this);
let css = `:root[animate-menupopups]
:not(menulist)
> menupopup:not([position], [type="arrow"], [animate="false"]) {
opacity: 0;
transform: translateY(-70px) scaleX(0.95) scaleY(0.5);
transform-origin: top;
transition-property: transform, opacity;
transition-duration: 0.18s, 0.18s;
transition-timing-function: var(--animation-easing-function, cubic-bezier(0.07, 0.95, 0, 1)),
ease-out;
transform-style: flat;
backface-visibility: hidden;
}
:root[animate-menupopups] :not(menulist) > menupopup:not([position], [type="arrow"])[animate][animate="open"] {
opacity: 1.0;
transition-duration: 0.18s, 0.18s;
transform: none !important;
transition-timing-function:
var(--animation-easing-function, cubic-bezier(.07, .95, 0, 1)), ease-in-out;
:root[animate-menupopups]
:not(menulist)
> menupopup:not([position], [type="arrow"])[animate][animate="open"] {
opacity: 1;
transition-duration: 0.18s, 0.18s;
transform: none !important;
transition-timing-function: var(--animation-easing-function, cubic-bezier(0.07, 0.95, 0, 1)),
ease-in-out;
}
:root[animate-menupopups] :not(menulist) > menupopup:not([position], [type="arrow"])[animate][animate="cancel"] {
transform: none;
:root[animate-menupopups]
:not(menulist)
> menupopup:not([position], [type="arrow"])[animate][animate="cancel"] {
transform: none;
}
:root[animate-menupopups] :not(menulist) > menupopup:not([position], [type="arrow"])[animating] {
pointer-events: none;
}
`;
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
let sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(
Ci.nsIStyleSheetService
);
let uri = Services.io.newURI("data:text/css;charset=UTF=8," + encodeURIComponent(css));
if (!sss.sheetRegistered(uri, sss.AUTHOR_SHEET))
sss.loadAndRegisterSheet(uri, sss.AUTHOR_SHEET);
}
handleEvent(e) {
if (e.target.tagName !== "menupopup") return;
if (e.target.hasAttribute("position")) return;
if (e.target.getAttribute("type") == "arrow") return;
if (e.target.parentElement) if (e.target.parentElement.tagName == "menulist") return;
if (
e.target.shadowRoot &&
e.target.shadowRoot.firstElementChild.classList.contains("panel-arrowcontainer")
)
return;
this[`on_${e.type}`](e);
}
on_popupshowing(e) {
if (e.target.getAttribute("animate") != "false") {
e.target.setAttribute("animate", "open");
e.target.setAttribute("animating", "true");
}
}
on_popupshown(e) {
e.target.removeAttribute("animating");
}
on_popuphidden(e) {
if (e.target.getAttribute("animate") != "false") e.target.removeAttribute("animate");
pointer-events: none;
}`;
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
let sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
let uri = Services.io.newURI("data:text/css;charset=UTF=8," + encodeURIComponent(css));
if (!sss.sheetRegistered(uri, sss.AUTHOR_SHEET))
sss.loadAndRegisterSheet(uri, sss.AUTHOR_SHEET);
}
handleEvent(e) {
if (e.target.tagName !== "menupopup") return;
if (e.target.hasAttribute("position")) return;
if (e.target.getAttribute("type") == "arrow") return;
if (e.target.parentElement) if (e.target.parentElement.tagName == "menulist") return;
if (
e.target.shadowRoot &&
e.target.shadowRoot.firstElementChild.classList.contains("panel-arrowcontainer")
)
return;
this[`on_${e.type}`](e);
}
on_popupshowing(e) {
if (e.target.getAttribute("animate") != "false") {
e.target.setAttribute("animate", "open");
e.target.setAttribute("animating", "true");
}
}
on_popupshown(e) {
e.target.removeAttribute("animating");
}
on_popuphidden(e) {
if (e.target.getAttribute("animate") != "false") e.target.removeAttribute("animate");
}
}

new AnimateContextMenus();
28 changes: 14 additions & 14 deletions JS/appMenuAboutConfigButton.uc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@
// user configuration
const config = {
urlOverride: "",
/* the script tries to automatically find earthlng's aboutconfig URL,
and if it can't be found, uses the built-in about:config URL instead. if
it's unable to find the URL for your particular setup, or if you just
want to use the vanilla about:config page, replace this empty string
with your preferred URL, in quotes. if you want to use my about:cfg
script that registers earthlng's aboutconfig page to about:cfg, and you
want the about:config button to take you to about:cfg, then leave this
empty. it will automatically use about:cfg if the script exists. if
about:cfg doesn't work for you then change the pathOverride in *that*
script instead of setting urlOverride in this one. if you changed the
address (the "cfg" string) in that script, you'll need to use
urlOverride here if you want the button to direct to earthlng's
aboutconfig page. so if for example you changed the address to "config2"
then change urlOverride above to "about:config2" */
/* the script tries to automatically find earthlng's aboutconfig URL, and if
it can't be found, uses the built-in about:config URL instead. if it's
unable to find the URL for your particular setup, or if you just want to
use the vanilla about:config page, replace this empty string with your
preferred URL, in quotes. if you want to use my about:cfg script that
registers earthlng's aboutconfig page to about:cfg, and you want the
about:config button to take you to about:cfg, then leave this empty. it
will automatically use about:cfg if the script exists. if about:cfg
doesn't work for you then change the pathOverride in *that* script
instead of setting urlOverride in this one. if you changed the address
(the "cfg" string) in that script, you'll need to use urlOverride here
if you want the button to direct to earthlng's aboutconfig page. so if
for example you changed the address to "config2" then change urlOverride
above to "about:config2" */
};

let { interfaces: Ci, manager: Cm } = Components;
Expand Down
Loading

0 comments on commit 4011ad7

Please sign in to comment.