Skip to content
This repository was archived by the owner on Jun 12, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const fixHeaders = ({requestHeaders}) => {
}

const filters = {
urls: [ "https://*.repubblica.it/*" ],
urls: [ "https://*.repubblica.it/*","https://*.economist.com/*" ],
types: [ "main_frame" ]
}
const opts = [ "blocking", "requestHeaders" ]
Expand Down
19 changes: 16 additions & 3 deletions freeRep.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name freeRep
// @version 1.6
// @version 1.5
// @include https://*.repubblica.it/*
// @include https://*.lastampa.it/*
// @include https://*.gazzetta.it/*_preview.shtml*
Expand All @@ -15,22 +15,29 @@ const checkAttr = (el, name, value) => {
}
return retv
}

function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

const checkClassName = (el, name) => el.classList && el.classList.contains(name)
const hide = el => { if (el) { el.style.display = "none" } }
const removeAttr = (el, name) => { el && el.attributes.removeNamedItem(name) }


const isPaywall = el => checkAttr(el, "subscriptions-section", "content")
const isPreview = el => checkAttr(el, "subscriptions-section", "content-not-granted")
const isBanner = el => checkClassName(el, "paywall-static")
const isNewPaywall = el => checkClassName(el, "paywall__content")
const isGazzettaPaywall = el => checkClassName(el, "bck-freemium__wall")
const isGazzettaPartnerLink = el => checkClassName(el, "is-partner-link")
const isGazzettaContent = el => checkAttr(el, "class", "content") // exact match
const isCorrierePaywall = el => checkClassName(el, "tp-iframe-wrapper")
const isCorriereBlackscreen = el => checkClassName(el, "tp-backdrop")

const isRepubblica = () => location.host.endsWith("repubblica.it")
const isLaStampa = () => location.host.endsWith("lastampa.it")
const isGazzettaIt = () => location.host.endsWith("gazzetta.it")
const isCorriere = () => location.host.endsWith("corriere.it")

const findLaStampaPaywall = () => document.querySelector("div.main-content > #article-body > iframe")

Expand Down Expand Up @@ -102,7 +109,13 @@ const freeRep = () => {
const el = findLaStampaPaywall();
if (el) {
el.replaceWith(createAmpLink())
}
}
}else if(isCorriere()){
sleep(1800).then(() => {
hide(findNode(document, isCorrierePaywall))
hide(findNode(document, isCorriereBlackscreen))
document.getElementsByTagName("body")[0].style = "overflow: visible !important"
})
} else {
const el = findNode(document, isNewPaywall);
if (el) {
Expand Down
8 changes: 6 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@
"permissions": [
"webRequest",
"webRequestBlocking",
"https://*.repubblica.it/*"
"https://*.repubblica.it/*",
"https://*.economist.com/*",
"https://*.corriere.it/*"
],
"content_scripts": [
{
"matches": [
"https://*.repubblica.it/*",
"https://*.lastampa.it/*",
"https://*.gazzetta.it/*_preview.shtml*"
"https://*.gazzetta.it/*_preview.shtml*",
"https://*.economist.com/*",
"https://*.corriere.it/*"
],
"run_at": "document_idle",
"js": [
Expand Down