NYTimes unpaywall

no subcribe popover to bother reader on nytimes.com

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         NYTimes unpaywall
// @namespace    phocks
// @version      0.1.3
// @description  no subcribe popover to bother reader on nytimes.com
// @author       phocks
// @match        *://www.nytimes.com/*
// @grant        GM_addStyle
// @run-at       document-start
// @license      MIT
// ==/UserScript==

GM_addStyle(`
  #site-content,
  .css-mcm29f {
    position: unset !important;
  }
  #gateway-content {
    display: none;
  }
  .css-gx5sib {
    display: none;
  }
`);

(function () {
  "use strict";

  const intervalId = setInterval(function () {
    const meteredContent = document.querySelector(".meteredContent");
    if (meteredContent !== null) {
      clearInterval(intervalId);

      let mutationsRemoved = [];
      let timeoutId;

      // Handle mutations to the metered content
      const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
          if (mutation.removedNodes.length > 0) {
            mutationsRemoved.push(mutation);
            // Reset the timeout to delay the execution of the function
            console.log(mutationsRemoved);
            clearTimeout(timeoutId);
            timeoutId = setTimeout(() => {
              observer.disconnect();
              mutationsRemoved.forEach((mutation) => {
                mutation.target.appendChild(mutation.removedNodes[0]);
              });
            }, 3000);
          }
        });
      });

      // Start observing the metered content
      observer.observe(meteredContent, { childList: true, subtree: true });
    }
  }, 10);

  setTimeout(function () {
    clearInterval(intervalId);
  }, 5000);
})();