Skip to content

Commit

Permalink
(JS) update autoHideNavbarSupport.uc.js
Browse files Browse the repository at this point in the history
to fix an oversight in a previous version.
switch to mozilla ESLint plugin, so add linter config
and refactor all scripts to clear the current linter config.
(CSS) fix some modal dialogs having abnormally large font size.
  • Loading branch information
aminomancer committed Aug 26, 2022
1 parent 2b4a435 commit f62a16d
Show file tree
Hide file tree
Showing 77 changed files with 3,642 additions and 3,376 deletions.
9 changes: 9 additions & 0 deletions .babel-eslint.rc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

module.exports = {
plugins: [
"@babel/plugin-syntax-jsx",
],
};
96 changes: 96 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

const path = require("path");

module.exports = {
parser: "@babel/eslint-parser",
parserOptions: {
sourceType: "script",
babelOptions: {
configFile: path.join(__dirname, ".babel-eslint.rc.js"),
},
},
settings: {
"import/extensions": [".mjs"],
},
rules: {
"no-implied-eval": "error",
"consistent-return": "off",
"no-empty": "off",
complexity: ["warn", { max: 50 }],
curly: ["error", "multi-line"],
"no-console": "warn",
"prettier/prettier": [
"error",
{
"endOfLine": "auto",
"arrowParens": "avoid",
"printWidth": 100,
"tabWidth": 2,
"trailingComma": "es5",
"quoteProps": "preserve",
},
],
},
ignorePatterns: ["node_modules", "utils/boot.jsm"],
// Ignore eslint configurations in parent directories.
root: true,
// New rules and configurations should generally be added in
// tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js to
// allow external repositories that use the plugin to pick them up as well.
extends: ["plugin:mozilla/recommended"],
plugins: ["mozilla", "import"],
overrides: [
{
files: ["*@aminomancer/**", "extensions/**"],
env: { webextensions: true },
},
{
// All .eslintrc.js files are in the node environment, so turn that
// on here.
// https://github.com/eslint/eslint/issues/13008
files: [".eslintrc.js"],
env: {
node: true,
browser: false,
},
},
{
files: ["*.mjs"],
rules: {
"import/default": "error",
"import/export": "error",
"import/named": "error",
"import/namespace": "error",
"import/newline-after-import": "error",
"import/no-anonymous-default-export": "error",
"import/no-duplicates": "error",
"import/no-absolute-path": "error",
"import/no-named-default": "error",
"import/no-named-as-default": "error",
"import/no-named-as-default-member": "error",
"import/no-self-import": "error",
"import/no-unassigned-import": "error",
"import/no-unresolved": [
"error",
// Bug 1773473 - Ignore resolver URLs for chrome and resource as we
// do not yet have a resolver for them.
{ ignore: ["chrome://", "resource://"] },
],
"import/no-useless-path-segments": "error",
},
},
{
files: ["*.html", "*.xhtml", "*.xml"],
rules: {
// Curly brackets are required for all the tree via recommended.js,
// however these files aren't auto-fixable at the moment.
curly: "off",
},
},
],
};
15 changes: 7 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
*.psd
*.prproj
custom-*.css
boot.jsm
resources/in-content/custom-content.css
node_modules
package-lock.json
package.json
*.psd
*.prproj
custom-*.css
node_modules/
package-lock.json
boot.jsm
resources/in-content/custom-content.css
47 changes: 47 additions & 0 deletions JS/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module.exports = {
env: {
node: false,
browser: true,
es2021: true,
"mozilla/browser-window": true,
"mozilla/jsm": true,
// "mozilla/chrome-worker": true,
// "mozilla/frame-script": true,
// "mozilla/privileged": true,
// "mozilla/simpletest": true,
// "mozilla/sjs": true,
// "mozilla/xpcshell": true,
},
parserOptions: {
sourceType: "script",
ecmaVersion: "latest",
},
overrides: [
{
files: [".eslintrc.js"],
env: {
node: true,
browser: false,
},
},
],
globals: {
_ucUtils: "writable",
windowUtils: "writable",
tabPreviews: "writable",
gUnifiedExtensions: "writable",
UIState: "writable",
FxAccounts: "writable",
EnsureFxAccountsWebChannel: "writable",
SyncedTabs: "writable",
MIN_STATUS_ANIMATION_DURATION: "writable",
SyncedTabsPanelList: "writable",
SyncedTabsDeckComponent: "writable",
syncedTabsDeckComponent: "writable",
},
rules: {
"no-eval": "off",
"mozilla/valid-lazy": "off",
"no-unused-vars": "off",
},
};
25 changes: 10 additions & 15 deletions JS/aboutCfg.uc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name about:cfg
// @version 1.2.2
// @version 1.2.3
// @author aminomancer
// @homepage https://github.com/aminomancer/uc.css.js
// @description Registers the old-school about:config page to the URL about:cfg. Intended for use with earthlng's aboutconfig module. That module restores the old about:config page, but gives it a long-winded URL like "chrome://userchromejs/content/aboutconfig/config.xhtml" which takes a lot longer to type in and doesn't look very elegant. This script finds the URL for that module and registers it to an about: URL so it counts as a chrome UI page. We're not just faking it, this makes it a bona-fide about: page. That means you can navigate to it by just typing about:cfg in the urlbar, and also means the identity icon will show it as a secure system page rather than a local file. It even means about:cfg will show up on the about:about page! This technically also makes using the aboutconfig module safer, because it denies the document access to some privileged stuff that it would have with a chrome:// URI. For instructions on installing earthlng's aboutconfig module for fx-autoconfig, please see the script description for App Menu about:config Button. This has only been tested with fx-autoconfig, but it may work with xiaoxiaoflood's loader. I don't think it will work with Alice0775's loader but I haven't tested it. Compatible with my appMenuAboutConfigButton.uc.js script. That button will automatically navigate to about:cfg if this script is installed. I recommend editing earthlng's config.xhtml file to remove line 13: title="about:config" This sets the tab title to about:config, which isn't necessary or desirable since we're changing the URL to about:cfg. Without the title attribute, firefox will automatically set the title to the tab's URL, which (with this script) is about:cfg.
Expand Down Expand Up @@ -28,7 +28,7 @@ const config = {
};

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

function findAboutConfig() {
Expand Down Expand Up @@ -58,17 +58,13 @@ function findAboutConfig() {
// 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(Services.uuid.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()
);
uuid = Components.ID(Services.uuid.generateUUID().toString());
}
return uuid;
}
Expand All @@ -82,36 +78,35 @@ VintageAboutConfig.prototype = {
if (!urlString) return null;
return this._uri || (this._uri = Services.io.newURI(urlString));
},
newChannel: function (_uri, loadInfo) {
newChannel(_uri, loadInfo) {
const ch = Services.io.newChannelFromURIWithLoadInfo(this.uri, loadInfo);
ch.owner = Services.scriptSecurityManager.getSystemPrincipal();
return ch;
},
getURIFlags: function (_uri) {
getURIFlags(_uri) {
return Ci.nsIAboutModule.ALLOW_SCRIPT | Ci.nsIAboutModule.IS_SECURE_CHROME_UI;
},
getChromeURI: function (_uri) {
getChromeURI(_uri) {
return this.uri;
},
QueryInterface: ChromeUtils.generateQI(["nsIAboutModule"]),
};

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

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

let EXPORTED_SYMBOLS = [];
Loading

0 comments on commit f62a16d

Please sign in to comment.