🏠 返回首頁 

Greasy Fork is available in English.

Make Reddit Great Again

Switches to old layout and restores old favicon


Installer dette script?
  1. // ==UserScript==
  2. // @name Make Reddit Great Again
  3. // @namespace Reddit
  4. // @match https://*.reddit.com/*
  5. // @icon https://www.redditstatic.com/favicon.ico
  6. // @grant none
  7. // @version 0.1
  8. // @description Switches to old layout and restores old favicon
  9. // @run-at document-start
  10. // ==/UserScript==
  11. // <link rel="icon" name="old-favicon" type="image/png" href="https://www.redditstatic.com/favicon.ico">
  12. var oldLink = document.getElementsByTagName('head')[0].querySelectorAll("link[rel='icon']");
  13. //console.log(oldLink.length);
  14. while(oldLink.length > 0)
  15. {
  16. document.getElementsByTagName('head')[0].removeChild(oldLink[0]);
  17. oldLink = document.getElementsByTagName('head')[0].querySelectorAll("link[rel='icon']");
  18. }
  19. //console.log(oldLink.length);
  20. var favicon = document.createElement('link');
  21. favicon.type = "image/png";
  22. favicon.rel = "icon";
  23. favicon.href = "https://www.redditstatic.com/favicon.ico";
  24. favicon.name = "old-favicon"
  25. document.getElementsByTagName('head')[0].appendChild(favicon);
  26. function test(url){
  27. return !!url.match(/^(|http(s?):\/\/)(|www.)reddit.com(\/.*|$)/gim);
  28. }
  29. function getNewPagePlease(url){
  30. return 'https://old.reddit.com' + url.split('reddit.com').pop();
  31. }
  32. function fixRedditStuff(){
  33. var links = Array.prototype.slice.call(document.links, 0);
  34. links.filter(function(link){
  35. if(test(link.href)){
  36. var greatNewLink = getNewPagePlease(link.href);
  37. if(link.hasAttribute('data-outbound-url')) link.setAttribute('data-outbound-url', greatNewLink);
  38. link.setAttribute('href', greatNewLink);
  39. }
  40. });
  41. }
  42. if(test(window.location.href)){window.location.assign(getNewPagePlease(window.location.href));}
  43. window.onload = fixRedditStuff;
  44. setInterval(fixRedditStuff, 50);