Dcard guest popup dismiss

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

目前为 2021-09-16 提交的版本。查看 最新版本

// ==UserScript==
// @name            Dcard guest popup dismiss
// @name:ZH-TW      Dcard 訪客瀏覽腳本
// @namespace       com.sherryyue.dcardguestmode
// @version         0.2
// @description     Dismiss the annoying login request pop-up and unlock scrolling restriction while not logging in.
// @author          SherryYue
// @match           *://*.dcard.tw/*
// @contributionURL https://github.com/SherryYueChiu/card
// @supportURL      [email protected]
// @icon            https://sherryyuechiu.github.io/card/images/logo/maskable_icon_x96.png
// @grant           none
// ==/UserScript==

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

  /** if popup exsist, dismiss it. */
  var loginPopupTraker = () => {
    $loginRequestPopup = document.querySelector(".__portal>*");
    if ($loginRequestPopup) {
      breakRestriction();
    }
  }

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

  // detect every 2 seconds
  setInterval(loginPopupTraker, 2000);
})();