Stack Exchange - 隱藏 Cookies 同意橫幅

隱藏 Stack Exchange 網站惱人的 Cookies 同意橫幅

  1. // ==UserScript==
  2. // @name Stack Exchange - Hide Cookies Consent Banner
  3. // @name:zh-TW Stack Exchange - 隱藏 Cookies 同意橫幅
  4. // @namespace https://github.com/jlhg/userscript
  5. // @license MIT
  6. // @version 0.1.2
  7. // @description Hide Stack Exchange websites' annoying cookies consent banner
  8. // @description:zh-TW 隱藏 Stack Exchange 網站惱人的 Cookies 同意橫幅
  9. // @author jlhg
  10. // @homepage https://github.com/jlhg/userscript
  11. // @supportURL https://github.com/jlhg/userscript/issues
  12. // @match https://*.stackexchange.com/*
  13. // @match https://stackoverflow.com/*
  14. // @match https://serverfault.com/*
  15. // @match https://superuser.com/*
  16. // @match https://mathoverflow.net/*
  17. // @match https://stackapps.com/*
  18. // @match https://askubuntu.com/*
  19. // @grant none
  20. // ==/UserScript==
  21.  
  22. // Other Notes
  23. // The match website list is referenced from https://stackexchange.com/sites.
  24.  
  25. (function() {
  26. 'use strict';
  27.  
  28. function waitElement(selector) {
  29. return new Promise(resolve => {
  30. if (document.querySelector(selector)) {
  31. return resolve(document.querySelector(selector));
  32. }
  33.  
  34. const observer = new MutationObserver(mutations => {
  35. if (document.querySelector(selector)) {
  36. observer.disconnect();
  37. resolve(document.querySelector(selector));
  38. }
  39. });
  40.  
  41. observer.observe(document.body, {
  42. childList: true,
  43. subtree: true
  44. });
  45. });
  46. }
  47.  
  48. waitElement('#onetrust-consent-sdk')
  49. .then((el) => { $(el).hide(); });
  50. })();

QingJ © 2025

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