Add Hide sticky elements
This commit is contained in:
parent
d319934631
commit
ee2cd8a08e
|
@ -0,0 +1,54 @@
|
||||||
|
// ==UserScript==
|
||||||
|
// @name Hide sticky elements
|
||||||
|
// @namespace blankie-scripts
|
||||||
|
// @match http*://*/*
|
||||||
|
// @grant GM_registerMenuCommand
|
||||||
|
// @grant GM_unregisterMenuCommand
|
||||||
|
// @version 1.0.0
|
||||||
|
// @author blankie
|
||||||
|
// @description Adds a button to the monkey menu to hide sticky elements
|
||||||
|
// @inject-into content
|
||||||
|
// ==/UserScript==
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
let stickyElements = [];
|
||||||
|
let hideStickyElements = true;
|
||||||
|
let menuId;
|
||||||
|
|
||||||
|
function hideAllStickyElements() {
|
||||||
|
for (let element of document.body.querySelectorAll("*")) {
|
||||||
|
let style = getComputedStyle(element);
|
||||||
|
if (style.position !== "sticky" && style.position !== "fixed") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let originalDisplayValue = element.style.getPropertyValue("display");
|
||||||
|
let originalDisplayPriority = element.style.getPropertyPriority("display");
|
||||||
|
element.style.setProperty("display", "none", "important");
|
||||||
|
stickyElements.push([element, originalDisplayValue, originalDisplayPriority]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function unhideAllStickyElements() {
|
||||||
|
for (let [element, originalDisplayValue, originalDisplayPriority] of stickyElements) {
|
||||||
|
element.style.setProperty("display", originalDisplayValue, originalDisplayPriority);
|
||||||
|
}
|
||||||
|
stickyElements = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function registerMenu() {
|
||||||
|
if (menuId) {
|
||||||
|
GM_unregisterMenuCommand(menuId);
|
||||||
|
}
|
||||||
|
|
||||||
|
let caption = hideStickyElements ? "Hide sticky elements" : "Unhide sticky elements";
|
||||||
|
menuId = GM_registerMenuCommand(caption, function() {
|
||||||
|
(hideStickyElements ? hideAllStickyElements : unhideAllStickyElements)();
|
||||||
|
hideStickyElements = !hideStickyElements;
|
||||||
|
registerMenu();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
registerMenu();
|
|
@ -50,6 +50,11 @@ A userscript that adds small but useful features for Compass. Features include:
|
||||||
A userscript that adds a "Show elements popup" option to the Monkey Menu which
|
A userscript that adds a "Show elements popup" option to the Monkey Menu which
|
||||||
lists all elements with an ID
|
lists all elements with an ID
|
||||||
|
|
||||||
|
## Hide sticky elements
|
||||||
|
|
||||||
|
A userscript that adds a button to the monkey menu to hide and unhide sticky
|
||||||
|
elements
|
||||||
|
|
||||||
## Image Loader Placeholder Remover
|
## Image Loader Placeholder Remover
|
||||||
|
|
||||||
Removes image loading placeholders from images loaded via Javascript, such as
|
Removes image loading placeholders from images loaded via Javascript, such as
|
||||||
|
|
Loading…
Reference in New Issue