您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Decline top menu move on page
- // ==UserScript==
- // @name Remove position fixed and sticky on top navbar
- // @namespace http://tampermonkey.net/
- // @version 0.2
- // @author DnAp
- // @description Decline top menu move on page
- // @include *
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- var maxDeep = 4;
- var replacePosition;
- var count = 0;
- replacePosition = function(element, deep) {
- if (['DIV', 'NAV', 'TABLE', 'SECTION'].indexOf(element.tagName) !== -1) {
- var css = window.getComputedStyle(element);
- var positionValue = css.position || "".replace(/\s/g, "").toLowerCase();
- if (positionValue === 'sticky') {
- element.style.position = 'static';
- count++;
- return;
- }
- if (positionValue === 'fixed' && parseInt(css.top || "0") === 0) {
- element.style.position = 'absolute';
- count++;
- return;
- }
- }
- deep++;
- if (deep >= maxDeep) {
- return;
- }
- for (var key = 0; key < element.children.length; key++) {
- replacePosition(element.children[key], deep);
- }
- };
- replacePosition(document.body, 0);
- console.warn("Remove position fixed for " + count + " elements");
- })();