Skip to content

Instantly share code, notes, and snippets.

@SWORDIntel
Created March 18, 2025 06:40
Show Gist options
  • Save SWORDIntel/616df7ba656563ca8bc2806868b6bb9a to your computer and use it in GitHub Desktop.
Save SWORDIntel/616df7ba656563ca8bc2806868b6bb9a to your computer and use it in GitHub Desktop.
ABCAM Tracking Bypass
// ==UserScript==
// @name Abcam Universal Redirector
// @namespace http://tampermonkey.net/
// @version 1.1
// @description Bypass Abcam tracking pages and remove tracking parameters from direct PDF links.
// @match *://go.myabcam.com/*
// @match *://docs.abcam.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
const host = window.location.hostname;
const url = new URL(window.location.href);
// Mapping overrides for specific guides
const mappingOverrides = {
"necroptosis-analysis-guide": { dir: "kits", filename: "necroptosis-guide.pdf" },
// Add additional mappings here if necessary:
// "some-other-guide": { dir: "folder", filename: "custom-filename.pdf" },
};
// For tracking URLs on go.myabcam.com, build and redirect to the direct PDF link
if (host.includes("go.myabcam.com")) {
// Get the slug from the pathname (removes leading/trailing slashes)
let slug = url.pathname.replace(/^\/+|\/+$/g, '');
if (slug) {
let newUrl = "";
if (mappingOverrides.hasOwnProperty(slug)) {
// Use custom mapping if available
newUrl = "https://docs.abcam.com/pdf/" + mappingOverrides[slug].dir + "/" + mappingOverrides[slug].filename;
} else {
// Default: assume the guide is in the 'general' folder with slug as filename
newUrl = "https://docs.abcam.com/pdf/general/" + slug + ".pdf";
}
console.log("Redirecting to: " + newUrl);
window.location.replace(newUrl);
}
}
// For docs.abcam.com PDF links that include tracking parameters, remove them.
else if (host.includes("docs.abcam.com")) {
// Check if we are on a PDF and there is a query string
if (url.pathname.endsWith(".pdf") && url.search) {
let cleanUrl = url.origin + url.pathname;
console.log("Stripping tracking parameters. Clean URL: " + cleanUrl);
// Replace current URL in the address bar without reloading the page
window.history.replaceState({}, document.title, cleanUrl);
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment