Fμck Facebook

Remove all Facebook shit

  1. // ==UserScript==
  2. // @name Fμck Facebook
  3. // @description Remove all Facebook shit
  4. // @namespace https://flandre.in/github
  5. // @version 1.7.0
  6. // @match https://*.facebook.com/*
  7. // @require https://unpkg.com/winkblue@0.1.1/dist/winkblue.umd.js
  8. // @resource faceBullshit https://raw.githubusercontent.com/FlandreDaisuki/My-Browser-Extensions/master/usercss/FaceBullshit.user.css
  9. // @grant GM_getValue
  10. // @grant GM.getValue
  11. // @grant GM_setValue
  12. // @grant GM.setValue
  13. // @grant GM_getResourceText
  14. // @grant GM.getResourceText
  15. // @noframes
  16. // @author FlandreDaisuki
  17. // @supportURL https://github.com/FlandreDaisuki/My-Browser-Extensions/issues
  18. // @homepageURL https://github.com/FlandreDaisuki/My-Browser-Extensions/blob/master/userscripts/F%CE%BCck%20Facebook/README.md
  19. // ==/UserScript==
  20.  
  21. (function () {
  22. 'use strict';
  23.  
  24. const noop = () => {};
  25. const $$ = (selectors) => Array.from(document.querySelectorAll(selectors));
  26.  
  27. const $el = (tag, attr = {}, cb = noop) => {
  28. const el = document.createElement(tag);
  29. if (typeof(attr) === 'string') {
  30. el.textContent = attr;
  31. }
  32. else {
  33. Object.assign(el, attr);
  34. }
  35. cb(el);
  36. return el;
  37. };
  38.  
  39. const $style = (stylesheet) => $el('style', stylesheet, (el) => document.head.appendChild(el));
  40.  
  41. const $getResourceText = (key) => {
  42. if (globalThis.GM_getResourceText) {
  43. return globalThis.GM_getResourceText(key);
  44. }
  45. else if (globalThis.GM.getResourceText){
  46. return globalThis.GM.getResourceText( key );
  47. }
  48. };
  49.  
  50. /* cSpell:ignoreRegExp \.[\w\d]{8}\b */
  51. /* cSpell:ignore posinset */
  52. /* global Winkblue */
  53. const { winkblue } = Winkblue;
  54.  
  55. /*
  56. 推薦與以下樣式一起使用,效果更佳
  57. https://github.com/FlandreDaisuki/My-Browser-Extensions/tree/master/usercss#facebullshit
  58. */
  59.  
  60. const faceBullshitStylesheetText = $getResourceText('faceBullshit');
  61. $style(faceBullshitStylesheetText
  62. .replace(/@-moz-document[^{]+[{]([\s\S]+)\n[}]/g, '$1')
  63. .replace(/(\n\s*)if[^{]+[{]([\s\S]+?)(\1[}])/g, '$2')
  64. .replace(/--chatroom-height: custom-chatroom-height;/g, '--chatroom-height: 92vh;'));
  65.  
  66. /* fix: Facebook 壞壞 */
  67. winkblue.on('html._8ykn', (htmlEl) => {
  68. // FaceBook add following rule to disable winkblue
  69.  
  70. // ._8ykn :not(.always-enable-animations){
  71. // animation-duration:0 !important;
  72. // animation-name:none !important;
  73. // transition-duration:0 !important;
  74. // transition-property:none !important
  75. // }
  76.  
  77. htmlEl.classList.remove('_8ykn');
  78. });
  79.  
  80. /* Feature 1: 刪掉贊助 */
  81.  
  82. // ref: https://openuserjs.org/scripts/burn/Facebook_Hide_Ads_(a.k.a._sponsored_posts)/source
  83. /* cSpell:disable */
  84. /* eslint-disable */
  85. const sponsorWords = {
  86. 'af': ['Geborg'],
  87. 'am': ['የተከፈለበት ማስታወቂያ'],
  88. 'ar': ['إعلان مُموَّل'],
  89. 'as': ['পৃষ্ঠপোষকতা কৰা'],
  90. 'ay': ['Yatiyanaka'],
  91. 'az': ['Sponsor dəstəkli'],
  92. 'be': ['Рэклама'],
  93. 'bg': ['Спонсорирано'],
  94. 'br': ['Paeroniet'],
  95. 'bs': ['Sponzorirano'],
  96. 'bn': ['সৌজন্যে'],
  97. 'ca': ['Patrocinat'],
  98. 'cb': ['پاڵپشتیکراو'],
  99. 'co': ['Spunsurizatu'],
  100. 'cs': ['Sponzorováno'],
  101. 'cx': ['Giisponsoran'],
  102. 'cy': ['Noddwyd'],
  103. 'da': ['Sponsoreret'],
  104. 'de': ['Gesponsert'],
  105. 'el': ['Χορηγούμενη'],
  106. 'en': ['Sponsored', 'Chartered'],
  107. 'eo': ['Reklamo'],
  108. 'es': ['Publicidad', 'Patrocinado'],
  109. 'et': ['Sponsitud'],
  110. 'eu': ['Babestua'],
  111. 'fa': ['دارای پشتیبانی مالی'],
  112. 'fi': ['Sponsoroitu'],
  113. 'fo': ['Stuðlað'],
  114. 'fr': ['Commandité', 'Sponsorisé'],
  115. 'fy': ['Sponsore'],
  116. 'ga': ['Urraithe'],
  117. 'gl': ['Patrocinado'],
  118. 'gn': ['Oñepatrosinapyre'],
  119. 'gx': ['Χορηγούμενον'],
  120. 'hi': ['प्रायोजित'],
  121. 'hu': ['Hirdetés'],
  122. 'id': ['Bersponsor'],
  123. 'it': ['Sponsorizzata'],
  124. 'ja': ['広告'],
  125. 'jv': ['Disponsori'],
  126. 'kk': ['Демеушілік көрсеткен'],
  127. 'km': ['បានឧបត្ថម្ភ'],
  128. 'lo': ['ໄດ້ຮັບການສະໜັບສະໜູນ'],
  129. 'mk': ['Спонзорирано'],
  130. 'ml': ['സ്പോൺസർ ചെയ്തത്'],
  131. 'mn': ['Ивээн тэтгэсэн'],
  132. 'mr': ['प्रायोजित'],
  133. 'ms': ['Ditaja'],
  134. 'ne': ['प्रायोजित'],
  135. 'nl': ['Gesponsord'],
  136. 'or': ['ପ୍ରଯୋଜିତ'],
  137. 'pa': ['ਸਰਪ੍ਰਸਤੀ ਪ੍ਰਾਪਤ'],
  138. 'pl': ['Sponsorowane'],
  139. 'ps': ['تمويل شوي'],
  140. 'pt': ['Patrocinado'],
  141. 'ru': ['Реклама'],
  142. 'sa': ['प्रायोजितः |'],
  143. 'si': ['අනුග්‍රහය දක්වන ලද'],
  144. 'so': ['La maalgeliyey'],
  145. 'sv': ['Sponsrad'],
  146. 'te': ['స్పాన్సర్ చేసినవి'],
  147. 'th': ['ได้รับการสนับสนุน'],
  148. 'tl': ['May Sponsor'],
  149. 'tr': ['Sponsorlu'],
  150. 'tz': ['ⵉⴷⵍ'],
  151. 'uk': ['Реклама'],
  152. 'ur': ['تعاون کردہ'],
  153. 'vi': ['Được tài trợ'],
  154. 'zh-Hans': ['赞助内容'],
  155. 'zh-Hant': ['贊助']
  156. }[document.documentElement.lang];
  157. /* eslint-enable */
  158. /* cSpell:enable */
  159.  
  160.  
  161. const FEED_ROOT_SELECTOR = '[role="feed"] > div, [role="article"], [aria-posinset]';
  162.  
  163. winkblue.on('svg use', (svgUseEl) => {
  164. const sponsorSvgTextEls = $$('svg text').filter((textEl) => sponsorWords.includes(textEl.textContent));
  165.  
  166. for (const sponsorSvgTextEl of sponsorSvgTextEls) {
  167. if (svgUseEl.attributes['xlink:href'].value !== `#${ sponsorSvgTextEl.id }`) { continue; }
  168.  
  169. const feedRootEl = svgUseEl.closest(FEED_ROOT_SELECTOR);
  170. if (!feedRootEl) { continue; }
  171.  
  172. /* eslint-disable-next-line no-console */
  173. console.count('🖕📘 NO_SPONSORS');
  174. feedRootEl.hidden = true;
  175. }
  176. });
  177.  
  178. winkblue.on('span[id^="jsc_c"], [aria-posinset] [attributionsrc] span[aria-labelledby] > span', (sponsorEl) => {
  179. const sponsorElText = sponsorEl.textContent;
  180. const hasSponsorWord = sponsorWords.some((word) => [...word].every((ch) => sponsorElText.includes(ch)));
  181. if (!hasSponsorWord) { return; }
  182.  
  183. const feedRootEl = sponsorEl.closest(FEED_ROOT_SELECTOR);
  184. if (!feedRootEl) { return; }
  185.  
  186. /* eslint-disable-next-line no-console */
  187. console.count('🖕📘 NO_SPONSORS');
  188. feedRootEl.hidden = true;
  189. });
  190.  
  191. })();

QingJ © 2025

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