Skip to content

Instantly share code, notes, and snippets.

@PlugFox
Last active November 30, 2024 02:06
Show Gist options
  • Save PlugFox/608ef9f5caecf87c820d8ffd9468cc72 to your computer and use it in GitHub Desktop.
Save PlugFox/608ef9f5caecf87c820d8ffd9468cc72 to your computer and use it in GitHub Desktop.
Bypass Medium paywall
// ==UserScript==
// @name medium-bypass
// @namespace plugfox
// @version 2024-03-19
// @description Bypass Medium paywall
// @author plugfox
// @run-at document-end
// @homepage https://gist.github.com/PlugFox/608ef9f5caecf87c820d8ffd9468cc72
// @homepageURL https://gist.github.com/PlugFox/608ef9f5caecf87c820d8ffd9468cc72
// @match *://medium.com/*
// @exclude *://medium.com/media/*
// @match *://*.medium.com/*
// @exclude *://*.medium.com/media/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Find paywall
function paywall() {
return window.location.pathname
&& window.location.pathname !== ""
&& window.location.pathname !== "/"
&& document.querySelectorAll('[aria-label="Member-only story"]').length > 0;
}
// Add freedium icon
function freediumButton() {
// Icon
const icon = document.createElement('div');
icon.title = 'Open with freedium.cfd';
icon.style.position = 'fixed';
icon.style.bottom = '16px';
icon.style.right = '16px';
icon.style.zIndex = '1000';
icon.style.cursor = 'pointer';
icon.style.width = '48px';
icon.style.height = '48px';
icon.style.backgroundColor = 'white';
icon.style.borderRadius = '50%';
icon.style.display = 'flex';
icon.style.alignItems = 'center';
icon.style.justifyContent = 'center';
icon.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.2)';
icon.style.fontSize = '24px';
icon.textContent = '💰';
// Tooltio
const tooltip = document.createElement('div');
tooltip.style.visibility = 'hidden';
tooltip.style.width = '200px';
tooltip.style.backgroundColor = 'rgba(0, 0, 0, 0.6)';
tooltip.style.color = 'white';
tooltip.style.textAlign = 'center';
tooltip.style.borderRadius = '8px';
tooltip.style.padding = '6px 0';
tooltip.style.position = 'absolute';
tooltip.style.zIndex = '1001';
tooltip.style.bottom = '100%';
tooltip.style.right = '25%';
//tooltip.style.marginLeft = '-60px';
tooltip.style.marginBottom = '5px';
tooltip.style.fontSize = '18px';
tooltip.textContent = 'Open with freedium.cfd';
// Append tooltip to icon
icon.appendChild(tooltip);
icon.addEventListener('mouseenter', function() {
tooltip.style.visibility = 'visible';
});
icon.addEventListener('mouseleave', function() {
tooltip.style.visibility = 'hidden';
});
// Handle click
icon.addEventListener('click', function() {
//console.log('hello');
//alert('hello');
const currentUrl = window.location.href;
window.open(`https://freedium.cfd/${currentUrl}`, '_blank');
});
// Append icon to body
document.body.appendChild(icon);
}
setTimeout(function() {
if (paywall()) freediumButton();
}, 1000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment