diff --git a/JS/restorePreProtonArrowpanels.uc.js b/JS/restorePreProtonArrowpanels.uc.js index 9b7057d0..d1cca1b6 100644 --- a/JS/restorePreProtonArrowpanels.uc.js +++ b/JS/restorePreProtonArrowpanels.uc.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Restore pre-Proton Arrowpanels -// @version 1.0.2 +// @version 1.0.3 // @author aminomancer // @homepage https://github.com/aminomancer/uc.css.js // @description The mother of all proton reversals. Probably my least favorite "feature" of the UI refresh has been the removal of arrows from arrowpanels. I'd call it misguided, except I can't comprehend what guided it in the first place. I mean — they're called arrowpanels, and that should really say it all. The point of arrows is to point at something. In this case, to point at the node to which the panel is anchored. Some might think it's enough that the popup simply be anchored to the node. That might be true for small elements like tooltips. But panels are big enough that they can be lined up with many nodes, especially when they're opened on a toolbar that's full of other buttons. It's not like there aren't other ways to see where the panel is anchored, but why give the user less information? Moreover, don't the arrows look good? This change, more than any of the other ones, feels like change for change's sake. Stripping things down merely for the sake of simplifying them. Anyway, this script will basically restore a bunch of stuff that was removed in Nightly 96.0a1. Arrowpanels' glory days are not behind them, not if I have anything to say about it... @@ -21,7 +21,7 @@ }, }); spec.prototype._setSideAttribute = function (event) { - if (!this.isArrowPanel || !this.isAnchored) { + if (!this.isArrowPanel || !event.isAnchored) { return; } @@ -46,7 +46,7 @@ let arrow = this.shadowRoot.querySelector(".panel-arrow"); if (arrow) { - arrow.hidden = !this.isAnchored; + arrow.hidden = !event.isAnchored; this.shadowRoot.querySelector(".panel-arrowbox").style.removeProperty("transform"); } @@ -97,7 +97,7 @@ this.panelContent.style.display = ""; } if (this.isArrowPanel && event.target == this) { - if (this.isAnchored && this.anchorNode) { + if (event.isAnchored && this.anchorNode) { let anchorRoot = this.anchorNode.closest("toolbarbutton, .anchor-root") || this.anchorNode; anchorRoot.setAttribute("open", "true"); @@ -105,7 +105,7 @@ let arrow = this.shadowRoot.querySelector(".panel-arrow"); if (arrow) { - arrow.hidden = !this.isAnchored; + arrow.hidden = !event.isAnchored; this.shadowRoot .querySelector(".panel-arrowbox") .style.removeProperty("transform"); diff --git a/resources/in-content/ext-ublock.css b/resources/in-content/ext-ublock.css index 2e49c02c..3186868a 100644 --- a/resources/in-content/ext-ublock.css +++ b/resources/in-content/ext-ublock.css @@ -6,7 +6,8 @@ /* uBlock Origin dark theme */ -@-moz-document regexp("^moz-extension://.*/.*") +/* @-moz-document regexp("^moz-extension://.*/.*") */ +@-moz-document url("disabled") { @media (prefers-color-scheme: dark) { :root[uc-extension-id="uBlock0@raymondhill.net"] { diff --git a/resources/in-content/system.css b/resources/in-content/system.css index a3a30bfa..60a6f694 100644 --- a/resources/in-content/system.css +++ b/resources/in-content/system.css @@ -634,7 +634,8 @@ } .container { - margin-inline-start: calc(3% + 65px) !important; + /* below: left align the text in about:reader */ + /* margin-inline-start: calc(3% + 65px) !important; */ max-width: var(--final-content-width) !important; } diff --git a/resources/script-override/customElements.js b/resources/script-override/customElements.js deleted file mode 100644 index 725eecd6..00000000 --- a/resources/script-override/customElements.js +++ /dev/null @@ -1,1151 +0,0 @@ -/* 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. */ - -"use strict"; - -// This script can be loaded by componentHacker.uc.js to basically override any custom element in the chrome document. -// Normally we wouldn't be able to do this with custom elements loaded at this widget level, but if we create the -// custom element registry before the browser can, by using "initial-document-element-inserted" instead of -// "document-element-inserted" we can instantiate our own versions of the custom element before firefox can. -// I'm not currently using this because any changes I make to something so major would require frequent updating. -// I decided to figure out how to do this with autoconfig because mozilla decided to get rid of the little anchor arrows -// shown on arrow panels. That's what tells you what button the panel is relevant to. This seems crazy to me. -// They're called arrowpanels for fuck's sake. So I obviously wanted to revert this asinine change for change's sake. -// But it's just not practical. Keeping up with updates would be a full-time job. At that point I might as well fork the browser. -// I don't have the time or expertise to do that, so we will just have to put up with arrowless arrowpanels. -// Maybe some of you even hated the arrows — who knows. -(() => { - // Handle customElements.js being loaded as a script in addition to the subscriptLoader - // from MainProcessSingleton, to handle pages that can open both before and after - // MainProcessSingleton starts. See Bug 1501845. - if (window.MozXULElement) { - return; - } - - const MozElements = {}; - window.MozElements = MozElements; - - const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); - const { AppConstants } = ChromeUtils.import("resource://gre/modules/AppConstants.jsm"); - const env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment); - const instrumentClasses = env.get("MOZ_INSTRUMENT_CUSTOM_ELEMENTS"); - const instrumentedClasses = instrumentClasses ? new Set() : null; - const instrumentedBaseClasses = instrumentClasses ? new WeakSet() : null; - - // If requested, wrap the normal customElements.define to give us a chance - // to modify the class so we can instrument function calls in local development: - if (instrumentClasses) { - let define = window.customElements.define; - window.customElements.define = function (name, c, opts) { - instrumentCustomElementClass(c); - return define.call(this, name, c, opts); - }; - window.addEventListener( - "load", - () => { - MozElements.printInstrumentation(true); - }, - { once: true, capture: true } - ); - } - - MozElements.printInstrumentation = function (collapsed) { - let summaries = []; - let totalCalls = 0; - let totalTime = 0; - for (let c of instrumentedClasses) { - // Allow passing in something like MOZ_INSTRUMENT_CUSTOM_ELEMENTS=MozXULElement,Button to filter - let includeClass = - instrumentClasses == 1 || - instrumentClasses - .split(",") - .some((n) => c.name.toLowerCase().includes(n.toLowerCase())); - let summary = c.__instrumentation_summary; - if (includeClass && summary) { - summaries.push(summary); - totalCalls += summary.totalCalls; - totalTime += summary.totalTime; - } - } - if (summaries.length) { - let groupName = `Instrumentation data for custom elements in ${document.documentURI}`; - console[collapsed ? "groupCollapsed" : "group"](groupName); - console.log( - `Total function calls ${totalCalls} and total time spent inside ${totalTime.toFixed( - 2 - )}` - ); - for (let summary of summaries) { - console.log(`${summary.name} (# instances: ${summary.instances})`); - if (Object.keys(summary.data).length > 1) { - console.table(summary.data); - } - } - console.groupEnd(groupName); - } - }; - - function instrumentCustomElementClass(c) { - // Climb up prototype chain to see if we inherit from a MozElement. - // Keep track of classes to instrument, for example: - // MozMenuCaption->MozMenuBase->BaseText->BaseControl->MozXULElement - let inheritsFromBase = instrumentedBaseClasses.has(c); - let classesToInstrument = [c]; - let proto = Object.getPrototypeOf(c); - while (proto) { - classesToInstrument.push(proto); - if (instrumentedBaseClasses.has(proto)) { - inheritsFromBase = true; - break; - } - proto = Object.getPrototypeOf(proto); - } - - if (inheritsFromBase) { - for (let c of classesToInstrument.reverse()) { - instrumentIndividualClass(c); - } - } - } - - function instrumentIndividualClass(c) { - if (instrumentedClasses.has(c)) { - return; - } - - instrumentedClasses.add(c); - let data = { instances: 0 }; - - function wrapFunction(name, fn) { - return function () { - if (!data[name]) { - data[name] = { time: 0, calls: 0 }; - } - data[name].calls++; - let n = performance.now(); - let r = fn.apply(this, arguments); - data[name].time += performance.now() - n; - return r; - }; - } - function wrapPropertyDescriptor(obj, name) { - if (name == "constructor") { - return; - } - let prop = Object.getOwnPropertyDescriptor(obj, name); - if (prop.get) { - prop.get = wrapFunction(` ${name}`, prop.get); - } - if (prop.set) { - prop.set = wrapFunction(` ${name}`, prop.set); - } - if (prop.writable && prop.value && prop.value.apply) { - prop.value = wrapFunction(name, prop.value); - } - Object.defineProperty(obj, name, prop); - } - - // Handle static properties - for (let name of Object.getOwnPropertyNames(c)) { - wrapPropertyDescriptor(c, name); - } - - // Handle instance properties - for (let name of Object.getOwnPropertyNames(c.prototype)) { - wrapPropertyDescriptor(c.prototype, name); - } - - c.__instrumentation_data = data; - Object.defineProperty(c, "__instrumentation_summary", { - enumerable: false, - configurable: false, - get() { - if (data.instances == 0) { - return null; - } - - let clonedData = JSON.parse(JSON.stringify(data)); - delete clonedData.instances; - let totalCalls = 0; - let totalTime = 0; - for (let d in clonedData) { - let { time, calls } = clonedData[d]; - time = parseFloat(time.toFixed(2)); - totalCalls += calls; - totalTime += time; - clonedData[d]["time (ms)"] = time; - delete clonedData[d].time; - clonedData[d].timePerCall = parseFloat((time / calls).toFixed(4)); - } - - let timePerCall = parseFloat((totalTime / totalCalls).toFixed(4)); - totalTime = parseFloat(totalTime.toFixed(2)); - - // Add a spaced-out final row with summed up totals - clonedData["\ntotals"] = { - "time (ms)": `\n${totalTime}`, - calls: `\n${totalCalls}`, - timePerCall: `\n${timePerCall}`, - }; - return { - instances: data.instances, - data: clonedData, - name: c.name, - totalCalls, - totalTime, - }; - }, - }); - } - - // The listener of DOMContentLoaded must be set on window, rather than - // document, because the window can go away before the event is fired. - // In that case, we don't want to initialize anything, otherwise we - // may be leaking things because they will never be destroyed after. - let gIsDOMContentLoaded = false; - const gElementsPendingConnection = new Set(); - window.addEventListener( - "DOMContentLoaded", - () => { - gIsDOMContentLoaded = true; - for (let element of gElementsPendingConnection) { - try { - if (element.isConnected) { - element.isRunningDelayedConnectedCallback = true; - element.connectedCallback(); - } - } catch (ex) { - console.error(ex); - } - element.isRunningDelayedConnectedCallback = false; - } - gElementsPendingConnection.clear(); - }, - { once: true, capture: true } - ); - - const gXULDOMParser = new DOMParser(); - gXULDOMParser.forceEnableXULXBL(); - - MozElements.MozElementMixin = (Base) => { - let MozElementBase = class extends Base { - constructor() { - super(); - - if (instrumentClasses) { - let proto = this.constructor; - while (proto && proto != Base) { - proto.__instrumentation_data.instances++; - proto = Object.getPrototypeOf(proto); - } - } - } - /* - * A declarative way to wire up attribute inheritance and automatically generate - * the `observedAttributes` getter. For example, if you returned: - * { - * ".foo": "bar,baz=bat" - * } - * - * Then the base class will automatically return ["bar", "bat"] from `observedAttributes`, - * and set up an `attributeChangedCallback` to pass those attributes down onto an element - * matching the ".foo" selector. - * - * See the `inheritAttribute` function for more details on the attribute string format. - * - * @return {Object} - */ - static get inheritedAttributes() { - return null; - } - - static get flippedInheritedAttributes() { - // Have to be careful here, if a subclass overrides inheritedAttributes - // and its parent class is instantiated first, then reading - // this._flippedInheritedAttributes on the child class will return the - // computed value from the parent. We store it separately on each class - // to ensure everything works correctly when inheritedAttributes is - // overridden. - if (!this.hasOwnProperty("_flippedInheritedAttributes")) { - let { inheritedAttributes } = this; - if (!inheritedAttributes) { - this._flippedInheritedAttributes = null; - } else { - this._flippedInheritedAttributes = {}; - for (let selector in inheritedAttributes) { - let attrRules = inheritedAttributes[selector].split(","); - for (let attrRule of attrRules) { - let attrName = attrRule; - let attrNewName = attrRule; - let split = attrName.split("="); - if (split.length == 2) { - attrName = split[1]; - attrNewName = split[0]; - } - - if (!this._flippedInheritedAttributes[attrName]) { - this._flippedInheritedAttributes[attrName] = []; - } - this._flippedInheritedAttributes[attrName].push([ - selector, - attrNewName, - ]); - } - } - } - } - - return this._flippedInheritedAttributes; - } - /* - * Generate this array based on `inheritedAttributes`, if any. A class is free to override - * this if it needs to do something more complex or wants to opt out of this behavior. - */ - static get observedAttributes() { - return Object.keys(this.flippedInheritedAttributes || {}); - } - - /* - * Provide default lifecycle callback for attribute changes that will inherit attributes - * based on the static `inheritedAttributes` Object. This can be overridden by callers. - */ - attributeChangedCallback(name, oldValue, newValue) { - if (oldValue === newValue || !this.initializedAttributeInheritance) { - return; - } - - let list = this.constructor.flippedInheritedAttributes[name]; - if (list) { - this.inheritAttribute(list, name); - } - } - - /* - * After setting content, calling this will cache the elements from selectors in the - * static `inheritedAttributes` Object. It'll also do an initial call to `this.inheritAttributes()`, - * so in the simple case, this is the only function you need to call. - * - * This should be called any time the children that are inheriting attributes changes. For instance, - * it's common in a connectedCallback to do something like: - * - * this.textContent = ""; - * this.append(MozXULElement.parseXULToFragment(`