Dcard guest popup dismiss

Dismiss the annoying login request pop-up and unlock scrolling restriction while not logging in.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name:zh-tw      Dcard 訪客瀏覽腳本
// @name            Dcard guest popup dismiss
// @namespace       com.sherryyue.dcardguestmode
// @version         0.6
// @description:zh-tw     隱藏登入彈窗並解除滾動限制,讓沒登入時也能輕鬆瀏覽Dcard。
// @description     Dismiss the annoying login request pop-up and unlock scrolling restriction while not logging in.
// @author          SherryYue
// @copyright       SherryYue
// @license         MIT
// @match           *://*.dcard.tw/*
// @contributionURL https://sherryyuechiu.github.io/card
// @supportURL      [email protected]
// @icon            https://sherryyuechiu.github.io/card/images/logo/maskable_icon_x96.png
// @supportURL      "https://github.com/sherryyuechiu/GreasyMonkeyScripts/issues"
// @homepage        "https://github.com/sherryyuechiu/GreasyMonkeyScripts"
// @grant           none
// ==/UserScript==

(function () {
  'use strict';
  /** login reqquest popup
   * @type HTMLElement */
  var $loginRequestPopup;

  /** dismiss the popup and break the scrolling restriction */
  var breakRestriction = () => {
    // hide login reqquest popup
    $loginRequestPopup.style.display = "none";
    // unlock scrolling restriction
    document.body.style.overflow = "auto";
  }

  let observer = new MutationObserver((mutations, obs) => {
    $loginRequestPopup = document.querySelector(".__portal>*");
    if ($loginRequestPopup) breakRestriction();
  });

  observer.observe(document.querySelector(".__portal"), {
    childList: true,
    subtree: true
  });
})();