QOL on the Web

Just some general quality of (my) life changes. Reddit: disable pinned top-bar, enforce old, hide sidebar on small screen. YouTube: disable end cards, enforce theatre-mode. Facebook: enforce most-recent. Duckduckgo: soften the ads.

  1. // ==UserScript==
  2. // @name QOL on the Web
  3. // @namespace Pogmog
  4. // @description Just some general quality of (my) life changes. Reddit: disable pinned top-bar, enforce old, hide sidebar on small screen. YouTube: disable end cards, enforce theatre-mode. Facebook: enforce most-recent. Duckduckgo: soften the ads.
  5. // @version 3.2
  6. // @include https://old.reddit.com/*
  7. // @include https://www.reddit.com/*
  8. // @include https://www.youtube.com/*
  9. // @include https://www.facebook.com/*
  10. // @include https://duckduckgo.com/?q=*
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. // Options
  15. var reddit_switch_to_old = true;
  16. var reddit_disable_side = true;
  17. var reddit_disable_pinned = true;
  18. var reddit_hide_automod_post = true;
  19. var youtube_always_theatre = true;
  20. var youtube_disable_endcards = true;
  21. var facebook_force_recent = true;
  22. var duckduckgo_ad_soften = true;
  23.  
  24. var urlCheck = document.URL;
  25. /*
  26. If a tweak needs to use the scroll or onLoad events, call them with the following:
  27. setup_onLoad()
  28. setup_onScroll()
  29. ...rather than have everything fire the onScroll event, etc.
  30. */
  31. if (urlCheck.includes("reddit.com/") && reddit_hide_automod_post)
  32. {
  33. setup_onLoad();
  34. }
  35.  
  36.  
  37. function afterLoad()
  38. {
  39. // If anything needs to happen after page load (did for Reddit stuff before I found a better way).
  40. if (urlCheck.includes("reddit.com/"))
  41. {
  42. if (reddit_hide_automod_post)
  43. {
  44. var first_comment = document.getElementsByClassName("comment")[0];
  45. var element_to_use = first_comment.getElementsByClassName("tagline")[0];
  46. var author = element_to_use.getElementsByClassName("author")[0];
  47. if (author.innerHTML == "AutoModerator")
  48. {
  49. console.log("First comment is Automod.");
  50. element_to_use.getElementsByClassName("expand")[0].onclick();
  51. }
  52. }
  53. }
  54. }
  55. function onPageScroll()
  56. {
  57. // If anything needs to happen on page scroll (did for Reddit stuff before I found a better way).
  58. }
  59.  
  60. if (urlCheck.includes("reddit.com/"))
  61. {
  62. if (urlCheck.includes("old.reddit.com/r/"))
  63. {
  64. if (reddit_disable_pinned)
  65. {
  66. // Reddit: hide the PINNED thing that pops up when you scroll down.
  67. var sheet = document.createElement('style')
  68. sheet.innerHTML = ".pinnable-placeholder .pinned {display: none;}";
  69. document.body.appendChild(sheet);
  70. }
  71. }
  72. else if (urlCheck.includes("www.reddit.com/"))
  73. {
  74. if (reddit_switch_to_old)
  75. {
  76. var new_url = urlCheck.replace("www.reddit.com", "old.reddit.com");
  77. window.location.href = new_url;
  78. }
  79. }
  80. if (reddit_disable_side)
  81. {
  82. var sheet = document.createElement('style')
  83. sheet.innerHTML = "@media only screen and (max-width: 975px) {.side {display: none; position:absolute; visibility: hidden;}body > .content {margin: 0;}}";
  84. document.body.appendChild(sheet);
  85. }
  86. }
  87. else if (urlCheck.includes("duckduckgo.com"))
  88. {
  89. var style = document.createElement('style');
  90. style.type = 'text/css';
  91. style.innerHTML = '#ads {border: solid darkcyan 2px;opacity: 0.5;border-radius: 10px;}';
  92. document.getElementsByTagName('head')[0].appendChild(style);
  93. }
  94. else if (urlCheck.includes("youtube.com/watch"))
  95. {
  96. if (youtube_disable_endcards)
  97. {
  98. // Get rid of YouTube's annoying ENDCARDS
  99. var sheet = document.createElement('style')
  100. sheet.innerHTML = ".ytp-ce-element {display: none;}";
  101. document.body.appendChild(sheet);
  102. }
  103. if (youtube_always_theatre)
  104. {
  105. // This code was lifted from r-a-y, namespace: "r-a-y/youtube/theater"
  106. window.addEventListener("yt-navigate-finish", function(event) {
  107. var newPlayer = document.querySelector('button.ytp-size-button');
  108. if ( newPlayer && null === document.querySelector('ytd-watch').getAttribute('theater') ) {
  109. newPlayer.click();
  110. }
  111. });
  112. }
  113. }
  114. else if (urlCheck.includes("facebook.com"))
  115. {
  116. if (facebook_force_recent)
  117. {
  118. // Check the main URL is the most recent
  119. if (urlCheck == "https://www.facebook.com/") window.location.href = "https://www.facebook.com/?sk=h_chr";
  120.  
  121. // Change all FB links to be the most_recent type.
  122. var fb_links = document.links;
  123. for (var i=0; i<fb_links.length; i++)
  124. {
  125. //Set up link to variable
  126. var p = fb_links[i].href;
  127. //If link is the raw FB link, replace.
  128. if(p == "https://www.facebook.com/" || p == "https://www.facebook.com/?ref=tn_tnmn" || p == "https://www.facebook.com/?ref=logo")
  129. {
  130. //Change to "most recent".
  131. fb_links[i].href = "https://www.facebook.com/?sk=h_chr";
  132. }
  133. }
  134. }
  135. }
  136.  
  137. // Functions that need to be called more than once:
  138. function reddit_removeSidebar()
  139. {
  140. var redditSidebar = document.getElementsByClassName("side")[0];
  141. redditSidebar.style.removeProperty("display");
  142. }
  143. // Setup Function
  144. function setup_onLoad()
  145. {
  146. // For code that needs to happen post-pageload
  147. if (window.attachEvent) {window.attachEvent('onload', afterLoad);}
  148. else if (window.addEventListener) {window.addEventListener('load', afterLoad, false);}
  149. else {document.addEventListener('load', afterLoad, false);}
  150. }
  151. function setup_onScroll()
  152. {
  153. // For code that needs to happen on scroll event
  154. window.addEventListener("scroll", onPageScroll);
  155. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址