Greasy Fork 还支持 简体中文。

Remove position fixed and sticky on top navbar

Decline top menu move on page

目前為 2018-11-05 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Remove position fixed and sticky on top navbar
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @author DnAp
  6. // @description Decline top menu move on page
  7. // @include *
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. var maxDeep = 4;
  14. var replacePosition;
  15. var count = 0;
  16.  
  17. replacePosition = function(element, deep) {
  18. if (['DIV', 'NAV', 'TABLE'].indexOf(element.tagName) !== -1) {
  19. var css = window.getComputedStyle(element);
  20. var positionValue = css.position || "".replace(/\s/g, "").toLowerCase();
  21. if (positionValue === 'sticky') {
  22. element.style.position = 'static';
  23. count++;
  24. return;
  25. }
  26.  
  27. if (positionValue === 'fixed' && parseInt(css.top || "0") === 0) {
  28. element.style.position = 'absolute';
  29. count++;
  30. return;
  31. }
  32. }
  33. deep++;
  34. if (deep >= maxDeep) {
  35. return;
  36. }
  37.  
  38. for (var key = 0; key < element.children.length; key++) {
  39. replacePosition(element.children[key], deep);
  40. }
  41. };
  42.  
  43. replacePosition(document.body, 0);
  44. console.warn("Remove position fixed for " + count + " elements");
  45. })();