Skip to content

Instantly share code, notes, and snippets.

@lucky-verma
Forked from mathix420/medium.user.js
Created July 11, 2024 23:48
Show Gist options
  • Save lucky-verma/6cf7fc201ee625d867300e65654180fa to your computer and use it in GitHub Desktop.
Save lucky-verma/6cf7fc201ee625d867300e65654180fa to your computer and use it in GitHub Desktop.

Revisions

  1. @mathix420 mathix420 revised this gist May 14, 2024. 1 changed file with 4 additions and 5 deletions.
    9 changes: 4 additions & 5 deletions medium.user.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    // @match *://medium.com/*
    // @match *://*/*
    // @grant none
    // @version 2.3
    // @version 2.4
    // @inject-into content
    // @updateURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    // @downloadURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    @@ -17,20 +17,19 @@

    // initCall is telling us if we need to inject the title observer
    function mediumRedirecter(initCall = false) {
    // I miss typescript...
    const mediumPostUrlProperty = ((document.head || {}).querySelector ? document.head.querySelector('meta[property="al:android:url"]') : {}) || {}

    if (
    // Allow seeing original articles that were already redirected to freedium.
    !window.location.href.endsWith('#bypass') &&
    // Do not redirect when editing on medium.
    !window.location.href.includes("/edit?source=") &&
    // Detect if we are on a medium website (regardless of the domain)
    (mediumPostUrlProperty.content && mediumPostUrlProperty.content.includes('medium://p/'))
    document.head?.querySelector('meta[property="al:android:url"]')?.content?.includes('medium://p/')
    ) {
    window.location.href = 'https://freedium.cfd/' + window.location.href;
    } else if (initCall && /(.*\.|^)medium\.com$/.test(window.location.host)) {
    // Observe <title> changes
    new MutationObserver(function(mutations) {
    // If title change is detected, check if a freedium redirect is required
    if (mutations[0].target.textContent) mediumRedirecter();
    }).observe(
    document.querySelector('title'),
  2. @mathix420 mathix420 revised this gist Apr 12, 2024. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions medium.user.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    // @match *://medium.com/*
    // @match *://*/*
    // @grant none
    // @version 2.2
    // @version 2.3
    // @inject-into content
    // @updateURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    // @downloadURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    @@ -18,7 +18,7 @@
    // initCall is telling us if we need to inject the title observer
    function mediumRedirecter(initCall = false) {
    // I miss typescript...
    const mediumPostUrlProperty = ((document.head || {}).querySelector || (() => ({})))('meta[property="al:android:url"]') || {}
    const mediumPostUrlProperty = ((document.head || {}).querySelector ? document.head.querySelector('meta[property="al:android:url"]') : {}) || {}

    if (
    // Allow seeing original articles that were already redirected to freedium.
  3. @mathix420 mathix420 revised this gist Apr 11, 2024. No changes.
  4. @mathix420 mathix420 revised this gist Apr 11, 2024. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions medium.user.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    // @match *://medium.com/*
    // @match *://*/*
    // @grant none
    // @version 2.1
    // @version 2.2
    // @inject-into content
    // @updateURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    // @downloadURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    @@ -17,7 +17,8 @@

    // initCall is telling us if we need to inject the title observer
    function mediumRedirecter(initCall = false) {
    const mediumPostUrlProperty = document.head.querySelector('meta[property="al:android:url"]') || {}
    // I miss typescript...
    const mediumPostUrlProperty = ((document.head || {}).querySelector || (() => ({})))('meta[property="al:android:url"]') || {}

    if (
    // Allow seeing original articles that were already redirected to freedium.
  5. @mathix420 mathix420 revised this gist Jan 21, 2024. 1 changed file with 3 additions and 5 deletions.
    8 changes: 3 additions & 5 deletions medium.user.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    // @match *://medium.com/*
    // @match *://*/*
    // @grant none
    // @version 2.0
    // @version 2.1
    // @inject-into content
    // @updateURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    // @downloadURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    @@ -17,17 +17,15 @@

    // initCall is telling us if we need to inject the title observer
    function mediumRedirecter(initCall = false) {
    const mediumPostUrlProperty = document.head.querySelector('meta[property="al:android:url"]')

    if (!(mediumPostUrlProperty || {}).content) return
    const mediumPostUrlProperty = document.head.querySelector('meta[property="al:android:url"]') || {}

    if (
    // Allow seeing original articles that were already redirected to freedium.
    !window.location.href.endsWith('#bypass') &&
    // Do not redirect when editing on medium.
    !window.location.href.includes("/edit?source=") &&
    // Detect if we are on a medium website (regardless of the domain)
    mediumPostUrlProperty.content.includes('medium://p/')
    (mediumPostUrlProperty.content && mediumPostUrlProperty.content.includes('medium://p/'))
    ) {
    window.location.href = 'https://freedium.cfd/' + window.location.href;
    } else if (initCall && /(.*\.|^)medium\.com$/.test(window.location.host)) {
  6. @mathix420 mathix420 revised this gist Jan 21, 2024. 1 changed file with 24 additions and 10 deletions.
    34 changes: 24 additions & 10 deletions medium.user.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    // @match *://medium.com/*
    // @match *://*/*
    // @grant none
    // @version 1.5
    // @version 2.0
    // @inject-into content
    // @updateURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    // @downloadURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    @@ -15,15 +15,29 @@
    // @description Don't forget to remove `@match` filters you don't want.
    // ==/UserScript==

    (function () {
    // 1. Allow seeing original articles that were already redirected to freedium.
    // 2. Do not redirect when editing on medium.
    if (window.location.href.endsWith('#bypass') || window.location.href.includes("/edit?source=")) {
    return;
    }

    // initCall is telling us if we need to inject the title observer
    function mediumRedirecter(initCall = false) {
    const mediumPostUrlProperty = document.head.querySelector('meta[property="al:android:url"]')
    if ((mediumPostUrlProperty || {}).content && mediumPostUrlProperty.content.includes('medium://p/')) {

    if (!(mediumPostUrlProperty || {}).content) return

    if (
    // Allow seeing original articles that were already redirected to freedium.
    !window.location.href.endsWith('#bypass') &&
    // Do not redirect when editing on medium.
    !window.location.href.includes("/edit?source=") &&
    // Detect if we are on a medium website (regardless of the domain)
    mediumPostUrlProperty.content.includes('medium://p/')
    ) {
    window.location.href = 'https://freedium.cfd/' + window.location.href;
    } else if (initCall && /(.*\.|^)medium\.com$/.test(window.location.host)) {
    new MutationObserver(function(mutations) {
    if (mutations[0].target.textContent) mediumRedirecter();
    }).observe(
    document.querySelector('title'),
    { subtree: true, characterData: true, childList: true }
    );
    }
    })();
    }

    mediumRedirecter(true);
  7. @mathix420 mathix420 revised this gist Jan 1, 2024. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions medium.user.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    // @match *://medium.com/*
    // @match *://*/*
    // @grant none
    // @version 1.4
    // @version 1.5
    // @inject-into content
    // @updateURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    // @downloadURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    @@ -16,8 +16,9 @@
    // ==/UserScript==

    (function () {
    // To allow seeing original articles that were already redirected to freedium.
    if (window.location.href.endsWith('#bypass')) {
    // 1. Allow seeing original articles that were already redirected to freedium.
    // 2. Do not redirect when editing on medium.
    if (window.location.href.endsWith('#bypass') || window.location.href.includes("/edit?source=")) {
    return;
    }

  8. @mathix420 mathix420 revised this gist Dec 16, 2023. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion medium.user.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,8 @@
    // @match *://medium.com/*
    // @match *://*/*
    // @grant none
    // @version 1.3
    // @version 1.4
    // @inject-into content
    // @updateURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    // @downloadURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    // @website https://freedium.cfd
  9. @mathix420 mathix420 revised this gist Nov 14, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion medium.user.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    // @match *://medium.com/*
    // @match *://*/*
    // @grant none
    // @version 1.2
    // @version 1.3
    // @updateURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    // @downloadURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    // @website https://freedium.cfd
  10. @mathix420 mathix420 revised this gist Nov 14, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions medium.user.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    // ==UserScript==
    // @name Medium Paywall Bypass
    // @namespace Violentmonkey Scripts
    // @run-at document-start
    // @match *://*.medium.com/*
    // @match *://medium.com/*
    // @match *://*/*
  11. @mathix420 mathix420 revised this gist Nov 8, 2023. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion medium.user.js
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    // @match *://medium.com/*
    // @match *://*/*
    // @grant none
    // @version 1.1
    // @version 1.2
    // @updateURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    // @downloadURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    // @website https://freedium.cfd
    @@ -14,6 +14,11 @@
    // ==/UserScript==

    (function () {
    // To allow seeing original articles that were already redirected to freedium.
    if (window.location.href.endsWith('#bypass')) {
    return;
    }

    const mediumPostUrlProperty = document.head.querySelector('meta[property="al:android:url"]')
    if ((mediumPostUrlProperty || {}).content && mediumPostUrlProperty.content.includes('medium://p/')) {
    window.location.href = 'https://freedium.cfd/' + window.location.href;
  12. @mathix420 mathix420 revised this gist Oct 27, 2023. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions medium.user.js
    Original file line number Diff line number Diff line change
    @@ -5,8 +5,11 @@
    // @match *://medium.com/*
    // @match *://*/*
    // @grant none
    // @version 1.0
    // @author Mathix420
    // @version 1.1
    // @updateURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    // @downloadURL https://gist.github.com/mathix420/e0604ab0e916622972372711d2829555/raw/medium.user.js
    // @website https://freedium.cfd
    // @author Mathix420, ZhymabekRoman
    // @description Don't forget to remove `@match` filters you don't want.
    // ==/UserScript==

  13. @mathix420 mathix420 revised this gist Oct 19, 2023. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion medium.user.js
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,8 @@
    // ==/UserScript==

    (function () {
    if (document.head.querySelector('meta[property="al:android:url"]').content.includes('medium://p/')) {
    const mediumPostUrlProperty = document.head.querySelector('meta[property="al:android:url"]')
    if ((mediumPostUrlProperty || {}).content && mediumPostUrlProperty.content.includes('medium://p/')) {
    window.location.href = 'https://freedium.cfd/' + window.location.href;
    }
    })();
  14. @mathix420 mathix420 revised this gist Oct 11, 2023. No changes.
  15. @mathix420 mathix420 revised this gist Sep 13, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion medium.user.js
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@
    // ==/UserScript==

    (function () {
    if (document.head.querySelector('meta[property="al:android:url"]').content.includes('medium://')) {
    if (document.head.querySelector('meta[property="al:android:url"]').content.includes('medium://p/')) {
    window.location.href = 'https://freedium.cfd/' + window.location.href;
    }
    })();
  16. @mathix420 mathix420 revised this gist Sep 13, 2023. No changes.
  17. @mathix420 mathix420 created this gist Sep 13, 2023.
    17 changes: 17 additions & 0 deletions medium.user.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    // ==UserScript==
    // @name Medium Paywall Bypass
    // @namespace Violentmonkey Scripts
    // @match *://*.medium.com/*
    // @match *://medium.com/*
    // @match *://*/*
    // @grant none
    // @version 1.0
    // @author Mathix420
    // @description Don't forget to remove `@match` filters you don't want.
    // ==/UserScript==

    (function () {
    if (document.head.querySelector('meta[property="al:android:url"]').content.includes('medium://')) {
    window.location.href = 'https://freedium.cfd/' + window.location.href;
    }
    })();