NYTimes unpaywall

no subcribe popover to bother reader on nytimes.com

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

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

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

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

您需要先安装一款用户脚本管理器扩展,例如 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);
})();