Greasy Fork is available in English.

Reddit: bring back old logo

Reverts to logo and icon that were before December 2023

  1. // ==UserScript==
  2. // @name Reddit: bring back old logo
  3. // @description Reverts to logo and icon that were before December 2023
  4. // @author Konf
  5. // @namespace https://greasyfork.org/users/424058
  6. // @icon https://i.imgur.com/ykdcVrp.png
  7. // @version 1.2.3
  8. // @match https://www.reddit.com/*
  9. // @compatible Chrome
  10. // @compatible Opera
  11. // @compatible Firefox
  12. // @require https://cdnjs.cloudflare.com/ajax/libs/arrive/2.4.1/arrive.min.js
  13. // @run-at document-start
  14. // @grant none
  15. // ==/UserScript==
  16.  
  17. /**
  18. * Hi! Don't change (or even resave) anything here because
  19. * by doing this in Tampermonkey you will turn off updates
  20. * of the script (idk about other script managers).
  21. * This could be restored in settings but it might be hard to find,
  22. * so better to reinstall the script if you're not sure
  23. */
  24.  
  25. (async function() {
  26. 'use strict';
  27.  
  28. const DARK_MODE_TEXT_COLOR = '#DADADA';
  29.  
  30. const icons = {
  31. '16': [
  32. 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9',
  33. 'hAAABn0lEQVR4AWySA6wdURRFp2ZcRTVi1w1q27YdJ7Vt27YV1HYbfNs2HtY/N+cm',
  34. 'j5Os8d6Hjv9BX6eOMEC4JiQJLkuycF0YaP7xKQLFzYSDQq4A4cm1/zQLJ74fVjSgl',
  35. 'lBT7qvpvb6/ryYqrm1dCcEI98+HQ0vgwlp4eR7GNoE+DlZT27F15YSIzU9jGsOR5S',
  36. 'raPgVenPMZqGagYxsGht6WXtZgSSfYOd08C9WgXw397gt0zbHdhv41YGYHoT1sHg+',
  37. 'vLkL0L4j8AY+Pw9phMKUFTG0N/apjDZKMgcu4sqwLpMVCdgoU5kJpIfaAsmIozIH0',
  38. 'OEiOhKVdsJm4Ag3yMgDg8kbYMEqFpUVyPxpu7ASAgmxY2SPAIEnQtEyXAb48gUfHw',
  39. 'FUJleVwew98uA8Ab276jzPJ10TjuH0qVFZARRnE/ddohTl6X14Kbhfsm+ffyGu+MZ',
  40. 'quD6kPl9ZDThr8/2CiKf/fa3nXt8PQhiFj9C2S+dC/po7v3Gp4ehqeCWaJlnfT1FX',
  41. 'sW6Swq9zbUjUcfJBaXPlhIqmZidjs/Bgq5oGenQGmGkYQ+gIA9QAAAABJRU5ErkJggg=='
  42. ].join(''),
  43.  
  44. '32': [
  45. 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr',
  46. '0AAAD5UlEQVR4Aa3XA5BcSxTG8Xm2XyEuxba1+2Lbtm3btm3btm3bdjK7//dN3b1V',
  47. '6d07ySCn6rc77tPudvkS5HJ9I0mlkyyWo/JY3BEey+GI9zpIEvnGFXCYBWeX8XJZw',
  48. 'oTPcMtFGSdZ5JtAC48jg+WeEKC7MlBi+lt4Vtkl4UKQwmWbZPC18HxyTvjCTkvo5w',
  49. 'rP5nfh/0mohESwn9tyGU5Jhk/1+U7BZ6FSPzUsGgrjWkLrUCgXA9rnhaUjoVdZyPN',
  50. 'N5O9tltiRC/9aBgt+JzCzO+xfDfMHwJ4VcHQLPLwFAI9uK8FUTi3RW77+OIEcAY/2',
  51. 'tZNhSF3I6YLCv0KDNHBmHwA8uAF1kjslcFcyW4XnVu2teY7ffV/0DziwFtrkMvu/c',
  52. 'UaY3B465De7wDREvvbUPplcCqj566WE49ugXCwVbr5HiDEInVySpK6I5TXM51rbP5',
  53. 'xTBtWALXMgz3dmgb5xS0NPAosEm2Mt7KYt9hd0yAcze8CKMXDhEFw6BgsHw8iGVv8',
  54. 'X+Mn8jt01uRxN8CRw1LGmVeNB/yrQPBuUiwljm8PJnfD2FY4RHg5PH1gzoX9lND6s',
  55. 'AdihAJSJ7i2JI54EHkepeZNMVs0Anj2AKyfA/R6f4+1razreuwYf3sPJXWi8OHXRY',
  56. '08C7ii1XzwMx3j9Ap7cgzC3QwuEwcsn8P4djjGjm1MCbt8TuHcVuhWHmolh3ZTIpc',
  57. 'PKcdAwLQytC0/vEyVm9fCawOMoCTRMB5ePY8SmWXrvG8jugla5zLHw6hk0ymy9l+d',
  58. '72LUMI66dRr/plMAjTwKHBUNOUU0gPOqPaLVjdm9r0Nnh/gAjG1mLTq2kcPUkRoxq',
  59. 'AiGOg/Cw8zQMkfb54d0bjLhzGU7vhjcviRLPHsLu5XD5GEaEhUGfCt4SGOtJoL3jO',
  60. 'NCuxqWjBB13r0DNRE7N/0EauCIOkBcc14JxLazmteP5Y5jdCw5vMlvn/Vs4uhVmdI',
  61. 'fHd8y1YWpnyPWVU+0vSGJ7Kx7rmEDh32HZSGsug/V/+wIYWB0GVLP6XRhYw7J1vpW',
  62. 'M3fRrJkKJf70tQgPkq4/PgHe8JjG6Cep/cz04ux92LbHosV4DsLdhazcs9o+3/eG2',
  63. 'pI98IBnoZQOSr6B2MpjYBg5vRPPcXIz0WCumtTNO6WgdQnJ9bdbc1N2u/cdJxJSt3',
  64. 'rffCIV/s5LpUhSt+VIFuhaDuimhyO/OZ0HTOonh7VyYUU77dQgVY9fM9UnHJfXnTs',
  65. 'YhjkkE77hk8fVukF42C19AuKyXVP7ejmJJb7krBOiOdJcYwVxOM8kQuSRuH49aF2S',
  66. 'gpP+St+Qk0lAmyBHM6/kjOSzjpIEk9rXg/wEYGM5JXiwPQwAAAABJRU5ErkJggg=='
  67. ].join(''),
  68.  
  69. '96': [
  70. 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc',
  71. '4AAAOsElEQVR4AezYQ7QlVxSH8X3R5iR2Mo6dzPpWVdsexbbtzFdscxrbts22+8V5',
  72. 'fl++2OqHy7PWb+/JZf0L55yotMHoKJLG2tpGs3SqrtJ9elXz9Zma1YHUrM80T6/qX',
  73. 'l2pUzVT25LEemTRX1FJLGU2LnL2kaSxtfbS+XpQn+oztYo11PqbYB7TRdpTW2ukYe',
  74. 'cU5WQpkzSGagcdpds1Xy2ilzVrvm7XcdpRQxXlYOlTea2vObpJ89QmyqRd83WT5mh',
  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hyEwh06aLiQknseS4eh7Qoj5Q4',
  105. 'l5H8Czy063t96cUeyb1kR36bWH+n0kltKUCRmkLnxnFH0uICTl3FhcQo1VufwZLVN',
  106. 'D2dXKARgrxnJk3BvgqH/CRDUwfBBw7lPI78s/8t5lDaDK5a0woYISlWvsROEcB3xc',
  107. 'F9mxN04ojRywd2MXn8L84Ni4DPs5mYicssLQiYG7XCk8IzCOjEatlZR7WVcJGS88D',
  108. 'imbxQty+jEZnTrGwTxloeUJWwCkIW7mQU/ohw9KMQUD+G3R2wQkq4FygCiDEg7VTI',
  109. '0S7e/QAsGczC+VS4TJFhBoeP8xDVJwEU7RuAd1tnRzUuchQwJH9wLBWwGfZgQqPSW',
  110. 'Lt9wrAwvF65o2Cp5vZ4XN6OJKeaPuRIObOGTCbG5cC5R/XVYCGCcp3HZEI+sJvXhv',
  111. 'IfRUfJCWXfpDAWnFj3RJfM6UvUOlJempwIvMooOzDwJhO+ruBgGC9KtwJ/UO4zYdc',
  112. 'TYGbHa78PJeAklBgVZ+XleaWGAgyMPRd4n2Zd1o6Rc9k9v2diUPtQ3iTlhta6Sl52',
  113. 'ECI9dzPcqS+hRnkDWzq3vR0+cZPsBRFLyZwE8caBCN6n6Ybqh+IRQM/lZR8jlvatV',
  114. 'FWuM9PoNeinrsA7uRxSSX4/CweRr08mN0RX8M8EjO4uoHYfDOpCCLMfikDbFgiqy+',
  115. 'tRKXVehXw+VFwu0/c2Wt6UOyY8aeAxgnAsYNwRaw98CBnMtE2k4poaywZV+8tYMtK',
  116. 'dzmYPwl+TS3WuAGY3Ne1CRKUXGzq3/mfagyo3JnMv6rSLJpKyLX5Lx192gxS7Sa6e',
  117. 'O5D+nKPXpjqtclRLNCwiyUwH73Kcxct1EvG8w5g1jCXuaKdQMN4IMFYOvozS83VPG',
  118. 'hEAflvBJZMdb9aGU3XeIk21XEV6eL+WBzYtBykgNxQusisgjkNesKFbgF6/QycOgG',
  119. 'SK5PZ4D1Txf8DSVzYUtOtNhlRAO3in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150. };
  151.  
  152. const svgs = {
  153. logo: {
  154. viewBox: '0 0 20 20',
  155. innerHTML: [
  156. '<g><circle fill="#FF4500" cx="10" cy="10" r="10"></circle><path f',
  157. 'ill="#FFF" d="M16.67,10A1.46,1.46,0,0,0,14.2,9a7.12,7.12,0,0,0-3.',
  158. '85-1.23L11,4.65,13.14,5.1a1,1,0,1,0,.13-0.61L10.82,4a0.31,0.31,0,',
  159. '0,0-.37.24L9.71,7.71a7.14,7.14,0,0,0-3.9,1.23A1.46,1.46,0,1,0,4.2',
  160. ',11.33a2.87,2.87,0,0,0,0,.44c0,2.24,2.61,4.06,5.83,4.06s5.83-1.82',
  161. ',5.83-4.06a2.87,2.87,0,0,0,0-.44A1.46,1.46,0,0,0,16.67,10Zm-10,1a',
  162. '1,1,0,1,1,1,1A1,1,0,0,1,6.67,11Zm5.81,2.75a3.84,3.84,0,0,1-2.47.7',
  163. '7,3.84,3.84,0,0,1-2.47-.77,0.27,0.27,0,0,1,.38-0.38A3.27,3.27,0,0',
  164. ',0,10,14a3.28,3.28,0,0,0,2.09-.61A0.27,0.27,0,1,1,12.48,13.79Zm-0',
  165. '.18-1.71a1,1,0,1,1,1-1A1,1,0,0,1,12.29,12.08Z"></path></g>'
  166. ].join(''),
  167. },
  168.  
  169. name: {
  170. viewBox: '0 0 57 18',
  171. innerHTML: [
  172. '<path d="M54.63,16.52V7.68h1a1,1,0,0,0,1.09-1V6.65a1,1,0,0,0-.93-',
  173. '1.12H54.63V3.88a1.23,1.23,0,0,0-1.12-1.23,1.2,1.2,0,0,0-1.27,1.11',
  174. 'V5.55h-1a1,1,0,0,0-1.09,1v.07a1,1,0,0,0,.93,1.12h1.13v8.81a1.19,1',
  175. '.19,0,0,0,1.19,1.19h0a1.19,1.19,0,0,0,1.25-1.12A.17.17,0,0,0,54.6',
  176. '3,16.52Z"></path><circle fill="#FF4500" cx="47.26" cy="3.44" r="2',
  177. '.12"></circle><path d="M48.44,7.81a1.19,1.19,0,1,0-2.38,0h0v8.71a',
  178. '1.19,1.19,0,0,0,2.38,0Z"></path><path d="M30.84,1.19A1.19,1.19,0,',
  179. '0,0,29.65,0h0a1.19,1.19,0,0,0-1.19,1.19V6.51a4.11,4.11,0,0,0-3-1.',
  180. '21c-3.1,0-5.69,2.85-5.69,6.35S22.28,18,25.42,18a4.26,4.26,0,0,0,3',
  181. '.1-1.23,1.17,1.17,0,0,0,1.47.8,1.2,1.2,0,0,0,.85-1.05ZM25.41,15.6',
  182. '4c-1.83,0-3.32-1.77-3.32-4s1.48-4,3.32-4,3.31,1.78,3.31,4-1.47,3.',
  183. '95-3.3,3.95Z"></path><path d="M43.28,1.19A1.19,1.19,0,0,0,42.09,0',
  184. 'h0a1.18,1.18,0,0,0-1.18,1.19h0V6.51a4.15,4.15,0,0,0-3-1.21c-3.1,0',
  185. '-5.69,2.85-5.69,6.35S34.72,18,37.86,18A4.26,4.26,0,0,0,41,16.77a1',
  186. '.17,1.17,0,0,0,1.47.8,1.19,1.19,0,0,0,.85-1.05ZM37.85,15.64c-1.83',
  187. ',0-3.31-1.77-3.31-4s1.47-4,3.31-4,3.31,1.78,3.31,4-1.47,3.95-3.3,',
  188. '3.95Z"></path><path d="M17.27,12.44a1.49,1.49,0,0,0,1.59-1.38v-.1',
  189. '5a4.81,4.81,0,0,0-.1-.85A5.83,5.83,0,0,0,13.25,5.3c-3.1,0-5.69,2.',
  190. '85-5.69,6.35S10.11,18,13.25,18a5.66,5.66,0,0,0,4.39-1.84,1.23,1.2',
  191. '3,0,0,0-.08-1.74l-.11-.09a1.29,1.29,0,0,0-1.58.17,3.91,3.91,0,0,1',
  192. '-2.62,1.12A3.54,3.54,0,0,1,10,12.44h7.27Zm-4-4.76a3.41,3.41,0,0,1',
  193. ',3.09,2.64H10.14A3.41,3.41,0,0,1,13.24,7.68Z"></path><path d="M7.',
  194. '68,6.53a1.19,1.19,0,0,0-1-1.18A4.56,4.56,0,0,0,2.39,6.91V6.75A1.2',
  195. ',1.2,0,0,0,0,6.75v9.77a1.23,1.23,0,0,0,1.12,1.24,1.19,1.19,0,0,0,',
  196. '1.26-1.1.66.66,0,0,0,0-.14v-5A3.62,3.62,0,0,1,5.81,7.7a4.87,4.87,',
  197. '0,0,1,.54,0h.24A1.18,1.18,0,0,0,7.68,6.53Z"></path></g>'
  198. ].join(''),
  199. },
  200. };
  201.  
  202. const q = {
  203. logoSvg: [
  204. // main
  205. 'svg._1O4jTk-dZ-VIxsCuYB6OR8',
  206.  
  207. // recap page, maybe somewhere else
  208. 'a#reddit-logo > span.pr-0.flex.items-center > svg',
  209.  
  210. // mobile useragent layout
  211. 'faceplate-tracker[noun="reddit_logo"] > a#reddit-logo > svg',
  212. ].join(', '),
  213.  
  214. nameSvg: [
  215. // main
  216. 'svg._1bWuGs_1sq4Pqy099x_yy-',
  217.  
  218. // recap page, maybe somewhere else
  219. 'a#reddit-logo > span.hidden.items-center > svg',
  220. ].join(', '),
  221. };
  222.  
  223. let logoSvgNode, nameSvgNode;
  224.  
  225. function setNameSvgNodeToDarkMode(node) {
  226. for (const child of node.children) {
  227. if (child.localName === 'path') {
  228. child.setAttribute('fill', DARK_MODE_TEXT_COLOR);
  229. }
  230. }
  231. }
  232.  
  233. function setNameSvgNodeToLightMode(node) {
  234. for (const child of node.children) {
  235. if (
  236. child.localName === 'path' &&
  237. child.attributes.fill?.value === DARK_MODE_TEXT_COLOR
  238. ) {
  239. child.removeAttribute('fill');
  240. }
  241. }
  242. }
  243.  
  244. const fixSvgNode = (() => {
  245. // is needed to avoid possible endless loop
  246. const nodesToSkip = new Set();
  247.  
  248. return (node, newSvg) => {
  249. if (nodesToSkip.has(node)) return;
  250.  
  251. nodesToSkip.add(node);
  252. node.innerHTML = newSvg.innerHTML;
  253. node.setAttribute('viewBox', newSvg.viewBox);
  254.  
  255. const nodeObs = new MutationObserver((mutations, observer) => {
  256. node.innerHTML = newSvg.innerHTML;
  257.  
  258. // check only for dark because light svg is default
  259. if (isItDarkMode() && node === nameSvgNode) {
  260. setNameSvgNodeToDarkMode(node);
  261. }
  262.  
  263. observer.takeRecords();
  264. });
  265.  
  266. nodeObs.observe(node, { childList: true });
  267.  
  268. // same as above
  269. if (isItDarkMode() && node === nameSvgNode) {
  270. setNameSvgNodeToDarkMode(node);
  271. }
  272. }
  273. })();
  274.  
  275. await waitForDocumentElement();
  276.  
  277. const documentObs = new MutationObserver((mutations) => {
  278. if (!nameSvgNode) return;
  279.  
  280. mutations.forEach((mutationRecord) => {
  281. if (mutationRecord.attributeName === 'class') {
  282. try {
  283. if (isItDarkMode()) {
  284. setNameSvgNodeToDarkMode(nameSvgNode);
  285. } else {
  286. setNameSvgNodeToLightMode(nameSvgNode);
  287. }
  288. } catch(e) {
  289. console.error(e);
  290. }
  291. }
  292. });
  293. });
  294.  
  295. documentObs.observe(document.documentElement, { attributes: true });
  296.  
  297. document.arrive('a[aria-label="Home"]', { existing: true }, (homeBtn) => {
  298. logoSvgNode = homeBtn.querySelector(q.logoSvg);
  299. nameSvgNode = homeBtn.querySelector(q.nameSvg);
  300.  
  301. if (logoSvgNode) fixSvgNode(logoSvgNode, svgs.logo);
  302. if (nameSvgNode) fixSvgNode(nameSvgNode, svgs.name);
  303.  
  304. const homeBtnObs = new MutationObserver((mutations) => {
  305. mutations.forEach((mutationRecord) => {
  306. for (const node of mutationRecord.addedNodes) {
  307. if (!node.matches) continue;
  308.  
  309. if (node.matches(q.logoSvg)) {
  310. fixSvgNode(node, svgs.logo);
  311. logoSvgNode = node;
  312. } else {
  313. const childNode = node.querySelector(q.logoSvg);
  314.  
  315. if (childNode) {
  316. fixSvgNode(childNode, svgs.logo);
  317. logoSvgNode = node;
  318. }
  319. }
  320.  
  321. if (node.matches(q.nameSvg)) {
  322. fixSvgNode(node, svgs.name);
  323. nameSvgNode = node;
  324. } else {
  325. const childNode = node.querySelector(q.nameSvg);
  326.  
  327. if (childNode) {
  328. fixSvgNode(childNode, svgs.name);
  329. nameSvgNode = node;
  330. }
  331. }
  332. }
  333. });
  334. });
  335.  
  336. homeBtnObs.observe(homeBtn, { childList: true });
  337. });
  338.  
  339. await waitForBodyElement();
  340.  
  341. for (const [size, base64] of Object.entries(icons)) {
  342. const link = document.createElement('link');
  343.  
  344. link.rel = 'icon';
  345. link.type = 'image/png';
  346. link.sizes = `${size}x${size}`;
  347. link.href = base64;
  348.  
  349. document.head.appendChild(link);
  350. }
  351.  
  352. // utils ===================================================================
  353.  
  354. function isItDarkMode() {
  355. if (document.documentElement.classList.contains('theme-dark')) {
  356. return true;
  357. }
  358. else if (document.documentElement.classList.contains('theme-light')) {
  359. return false;
  360. }
  361.  
  362. throw new Error('Can\'t figure out is it dark or light mode');
  363. }
  364.  
  365. async function waitForBodyElement() {
  366. return new Promise((resolve) => {
  367. (function trackerLoop() {
  368. if (!document.body) return setTimeout(trackerLoop);
  369. resolve();
  370. }());
  371. });
  372. }
  373.  
  374. async function waitForDocumentElement() {
  375. return new Promise((resolve) => {
  376. (function trackerLoop() {
  377. if (!document.documentElement) return setTimeout(trackerLoop);
  378. resolve();
  379. }());
  380. });
  381. }
  382.  
  383. })();