Ryonez

userChrome.js

Sep 3rd, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.99 KB | None | 0 0
  1. // ==UserScript==
  2. // @name userChrome.js
  3. // @namespace scrollbars_win10
  4. // @version 0.0.7
  5. // @note Windows 10 style by /u/mrkwatz https://www.reddit.com/r/FirefoxCSS/comments/7fkha6/firefox_57_windows_10_uwp_style_overlay_scrollbars/
  6. // @note Brought to Firefox 57 by /u/Wiidesire https://www.reddit.com/r/firefox/comments/7f6kc4/floating_scrollbar_finally_possible_in_firefox_57/
  7. // @note userChrome.js https://github.com/nuchi/firefox-quantum-userchromejs
  8. // @note Forked from https://github.com/Endor8/userChrome.js/blob/master/floatingscrollbar/FloatingScrollbar.uc.js
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. var prefs = Services.prefs,
  13. enabled;
  14. if (prefs.prefHasUserValue('userChromeJS.floating_scrollbar.enabled')) {
  15. enabled = prefs.getBoolPref('userChromeJS.floating_scrollbar.enabled')
  16. } else {
  17. prefs.setBoolPref('userChromeJS.floating_scrollbar.enabled', true);
  18. enabled = true;
  19. }
  20.  
  21. var css = `
  22. @namespace url(http: //www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
  23. :not(select):not(hbox) > scrollbar {
  24. -moz-appearance: none!important;
  25. position: relative!important;
  26. background-color: transparent;
  27. pointer-events: none;
  28. z-index: 2147483647;
  29. }
  30. :not(select):not(hbox) > scrollbar * {
  31. -moz-appearance: none!important;
  32. background-color: transparent!important;
  33. pointer-events: none;
  34. }
  35. :not(select):not(hbox) > scrollbar thumb {
  36. -moz-appearance: none!important;
  37. background-color: transparent;
  38. pointer-events: auto;
  39. }
  40. :not(select):not(hbox) > scrollbar[orient = "vertical"] {
  41. min-width: 12px!important;
  42. -moz-margin-start: -12px;/*margin to fill the whole render window with content and overlay the scrollbars*/
  43. }
  44. :not(select):not(hbox) > scrollbar[orient = "horizontal"] {
  45. height: 12px!important;
  46. margin-top: -12px;
  47. }
  48. :not(select):not(hbox) > scrollbar[orient = "vertical"] thumb {
  49. border-right: 2px solid rgba(133, 132, 131, 1);
  50. width: 12px;
  51. min-height: 12px;
  52. transition: border 0.1s ease-in;
  53. }
  54. :not(select):not(hbox) > scrollbar[orient = "horizontal"] thumb {
  55. border-bottom: 2px solid rgba(133, 132, 131, 1);
  56. min-width: 12px;
  57. transition: border 0.1s ease-in;
  58. }
  59. :not(select):not(hbox) > scrollbar:hover {
  60. background-color: rgba(0, 0, 0, 0.25);
  61. max-width: 12px!important;
  62. point-events: auto;
  63. }
  64. :not(select):not(hbox) > scrollbar:hover thumb {
  65. border-width: 12px;
  66. transition: border 0s linear;
  67. }
  68. :not(select):not(hbox) > scrollbar scrollbarbutton, :not(select):not(hbox) > scrollbar gripper {
  69. display: none;
  70. }
  71. @-moz-document domain("youtube.com") {
  72. :not(select):not(hbox) > scrollbar[orient = "vertical"]:not(:hover) thumb {
  73. opacity: 0 !important;
  74. }
  75. }
  76. `;
  77.  
  78. var sss = Cc['@mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService);
  79. var uri = makeURI('data:text/css;charset=UTF=8,' + encodeURIComponent(css));
  80.  
  81. var p = document.getElementById('devToolsSeparator');
  82. var m = document.createElement('menuitem');
  83. m.setAttribute('label', "Windows 10 Style Scrollbars");
  84. m.setAttribute('type', 'checkbox');
  85. m.setAttribute('autocheck', 'false');
  86. m.setAttribute('checked', enabled);
  87. p.parentNode.insertBefore(m, p);
  88. m.addEventListener('command', command, false);
  89.  
  90. if (enabled) {
  91. sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET);
  92. }
  93.  
  94. function command() {
  95. if (sss.sheetRegistered(uri, sss.AGENT_SHEET)) {
  96. prefs.setBoolPref('userChromeJS.floating_scrollbar.enabled', false);
  97. sss.unregisterSheet(uri, sss.AGENT_SHEET);
  98. m.setAttribute('checked', false);
  99. } else {
  100. prefs.setBoolPref('userChromeJS.floating_scrollbar.enabled', true);
  101. sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET);
  102. m.setAttribute('checked', true);
  103. }
  104.  
  105. let root = document.documentElement;
  106. let display = root.style.display;
  107. root.style.display = 'none';
  108. window.getComputedStyle(root).display; // Flush
  109. root.style.display = display;
  110. }
  111.  
  112. })();
Add Comment
Please, Sign In to add comment