您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Unfixes sticky elements such as navigation bar. Default keymap: ctrl+alt+u
当前为
// ==UserScript== // @name Unfix // @namespace com.gmail.fujifruity.greasemonkey // @version 1.0 // @description Unfixes sticky elements such as navigation bar. Default keymap: ctrl+alt+u // @author fujifruity // @match *://*/* // @grant none // ==/UserScript== (() => { let log = (...msg) => console.log("Unfix:", ...msg) // Gets the css of the element function cssOf(elem) { return document.defaultView.getComputedStyle(elem, '') } function isFixed(elem) { return ['fixed', 'sticky'].includes(cssOf(elem).position) } // Unfixes the element function unfix(elem) { if (isFixed(elem)) { elem.style.setProperty('position', 'unset', 'important') log('unfixed:', elem) } } // Keeps all elements unfixed function unfixForever() { // Unfix all fixed elements let allElems = Array.from(document.body.getElementsByTagName("*")) allElems.forEach(unfix) // Start observing elements get fixed let observer = new window.MutationObserver((mutationRecords) => { mutationRecords.forEach((mutationRecord) => { unfix(mutationRecord.target) }) }) let config = { attributes: true, subtree: true } observer.observe(document.body, config) log('observing...') } // Set a shortcut window.addEventListener('keydown', (event) => { if (event.key == 'u' && event.ctrlKey == true && event.altKey == true) { unfixForever() log('keydown') } }) log('set shortcut') })();