La Repubblica "Rep" Paywall Bypass

Unhides the "paywalled" articles on Rep.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name                La Repubblica "Rep" Paywall Bypass
// @name:it             La Repubblica "Rep" Paywall Bypass
// @namespace           LucciUserJS
// @version             2.1.1
// @description         Unhides the "paywalled" articles on Rep.
// @description:it      Rimuove il paywall su Rep, gli articoli premium di la Repubblica.it.
// @author              Lucci <[email protected]>, Andrea Lazzarotto
// @match               https://rep.repubblica.it/*
// @license             GPL version 3 or any later version http://www.gnu.org/copyleft/gpl.html
// ==/UserScript==

const addStyle = function(css) {
  /**
   * Inject CSS into the document.
   * 
   * This is a standalone implementation of GM_addStyle, which is 
   * deprecated by Greasemonkey but still supported by other extensions.
   * 
   * Inspired by Tampermonkey's TM_addStyle function, which is 
   * Tampermonkey's own implementation of GM_addStyle.
   **/
  try {
    let style = document.createElement('style');
    style.textContent = css;
    parent = (document.head || document.body || document.documentElement || document);
    parent.appendChild(style);
  } catch (e) {
    console.log("Error: " + e);
  }
};

const redirect = function() {
    var pwa = location.href.indexOf("/pwa/") > 0;
    var comments = location.pathname.endsWith("/commenti");
    if (pwa && !comments) {
        location.href = location.href.replace("/pwa/", "/ws/detail/");
    }
};

(function () {
  'use strict';
  redirect()
  addStyle(
    `
    div.detail-article_body > div:not(.paywall) { 
      display: none !important;
    }
    div.detail-article_body > div.paywall, 
    body:not(.i-amphtml-subs-grant-yes) [subscriptions-section='content'] { 
      display: block !important; 
    }
    `
  );
  window.dispatchEvent(new Event('resize'));
})()