Dcard guest popup dismiss

隱藏登入彈窗並解除滾動限制,讓沒登入時也能輕鬆瀏覽Dcard。

目前为 2024-08-15 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name:zh-tw Dcard 訪客瀏覽腳本
  3. // @name Dcard guest popup dismiss
  4. // @namespace com.sherryyue.dcardguestmode
  5. // @version 0.6
  6. // @description 隱藏登入彈窗並解除滾動限制,讓沒登入時也能輕鬆瀏覽Dcard。
  7. // @description Dismiss the annoying login request pop-up and unlock scrolling restriction while not logging in.
  8. // @author SherryYue
  9. // @copyright SherryYue
  10. // @license MIT
  11. // @match *://*.dcard.tw/*
  12. // @contributionURL https://sherryyuechiu.github.io/card
  13. // @supportURL sherryyue.c@protonmail.com
  14. // @icon https://sherryyuechiu.github.io/card/images/logo/maskable_icon_x96.png
  15. // @supportURL "https://github.com/sherryyuechiu/GreasyMonkeyScripts/issues"
  16. // @homepage "https://github.com/sherryyuechiu/GreasyMonkeyScripts"
  17. // @grant none
  18. // ==/UserScript==
  19.  
  20. (function () {
  21. 'use strict';
  22. /** login reqquest popup
  23. * @type HTMLElement */
  24. var $loginRequestPopup;
  25.  
  26. /** dismiss the popup and break the scrolling restriction */
  27. var breakRestriction = () => {
  28. // hide login reqquest popup
  29. $loginRequestPopup.style.display = "none";
  30. // unlock scrolling restriction
  31. document.body.style.overflow = "auto";
  32. }
  33.  
  34. let observer = new MutationObserver((mutations, obs) => {
  35. $loginRequestPopup = document.querySelector(".__portal>*");
  36. if ($loginRequestPopup) breakRestriction();
  37. });
  38.  
  39. observer.observe(document.querySelector(".__portal"), {
  40. childList: true,
  41. subtree: true
  42. });
  43. })();