Medium Upsell Blocker

Prevent Medium subscription/upsell modals by setting lo-non-moc-upsell-v2|displayed-at in localStorage

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name               Medium Upsell Blocker
// @name:zh-TW         Medium 推銷遮罩阻擋器
// @namespace          wellstsai.com
// @version            v20251112
// @license            MIT
// @description        Prevent Medium subscription/upsell modals by setting lo-non-moc-upsell-v2|displayed-at in localStorage
// @description:zh-TW  透過在 localStorage 中設定 lo-non-moc-upsell-v2|displayed-at,防止 Medium 顯示訂閱或推銷彈出視窗
// @author             WellsTsai
// @match              *://*.medium.com/*
// @match              *://*/*
// @run-at             document-start
// @grant              none
// ==/UserScript==

(() => {
    'use strict';
    const K = 'lo-non-moc-upsell-v2|displayed-at';
    const set = () => { try { localStorage.setItem(K, `"${new Date().toISOString()}"`); } catch (_) {} };
    const isMediumHost = /(^|\.)medium\.com$/.test(location.hostname);
    const isMediumLike = () => {
        const nodes = document.querySelectorAll('meta[name],meta[property],link[href]');
        for (const el of nodes) {
            const s = `${el.content||''}${el.getAttribute('name')||''}${el.getAttribute('property')||''}${el.href||''}`.toLowerCase();
            if (s.includes('medium') || s.includes('com.medium.reader') || s.includes('miro.medium.com') || s.includes('glyph.medium.com')) return true;
        }
        return false;
    };

    if (isMediumHost) {
        set();
        window.addEventListener('DOMContentLoaded', set, { once: true });
    } else {
        const run = () => { if (isMediumLike()) set(); };
        if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run, { once: true });
        else run();
    }
})();