Skip to content

Instantly share code, notes, and snippets.

@SWORDIntel
Created March 29, 2025 11:42
Show Gist options
  • Save SWORDIntel/154cea47372b45b40f531076aaf5a316 to your computer and use it in GitHub Desktop.
Save SWORDIntel/154cea47372b45b40f531076aaf5a316 to your computer and use it in GitHub Desktop.
ABCAM,COM PII BYPASS
// ==UserScript==
// @name Abcam Adaptive Direct PDF Redirector
// @namespace http://tampermonkey.net/
// @version 1.269420
// @description Adaptive mechanism to bypass Abcam tracking pages by testing candidate PDF URLs based on heuristics, then redirecting to the working link. Also cleans direct PDF URLs.
// @match *://go.myabcam.com/*
// @match *://docs.abcam.com/*
// @grant GM_xmlhttpRequest
// @connect docs.abcam.com
// ==/UserScript==
(function() {
'use strict';
const host = window.location.hostname;
const currentUrl = new URL(window.location.href);
// Function to perform a HEAD request to check if a URL exists.
function checkUrl(url) {
return new Promise((resolve) => {
GM_xmlhttpRequest({
method: "HEAD",
url: url,
onload: function(response) {
// Consider HTTP 200 as a valid response.
if (response.status === 200) {
resolve(true);
} else {
resolve(false);
}
},
onerror: function() {
resolve(false);
}
});
});
}
// Adaptive mechanism for go.myabcam.com pages.
async function processGoMyAbcam() {
// Extract the slug from the pathname (e.g. "necroptosis-analysis-guide")
let slug = currentUrl.pathname.replace(/^\/+|\/+$/g, '');
if (!slug) {
return;
}
// Build a list of candidate URLs.
const baseUrl = "https://docs.abcam.com/pdf/";
let candidates = [];
// Candidate 1: Assume in "general" folder with the slug as filename.
candidates.push(baseUrl + "general/" + slug + ".pdf");
// If the slug contains "analysis", try the "kits" folder with "-analysis" removed.
if (slug.toLowerCase().includes("analysis")) {
let modifiedSlug = slug.replace(/-analysis/gi, "");
candidates.push(baseUrl + "kits/" + modifiedSlug + ".pdf");
}
// If the slug contains "guide", try stripping "-guide" and check in "general"
if (slug.toLowerCase().includes("guide")) {
let modifiedSlug = slug.replace(/-guide/gi, "");
candidates.push(baseUrl + "general/" + modifiedSlug + ".pdf");
}
// Remove duplicate candidates.
candidates = Array.from(new Set(candidates));
console.log("Candidate URLs:", candidates);
// Try each candidate sequentially until one exists.
for (let candidate of candidates) {
let exists = await checkUrl(candidate);
if (exists) {
console.log("Redirecting to:", candidate);
window.location.replace(candidate);
return;
}
}
console.log("No valid candidate URL found. No redirection performed.");
}
// Clean up docs.abcam.com URLs by stripping query parameters.
function processDocsAbcam() {
if (currentUrl.pathname.endsWith(".pdf") && currentUrl.search) {
let cleanUrl = currentUrl.origin + currentUrl.pathname;
console.log("Stripping tracking parameters. Clean URL:", cleanUrl);
window.history.replaceState({}, document.title, cleanUrl);
}
}
// Determine which domain we're on and process accordingly.
if (host.includes("go.myabcam.com")) {
processGoMyAbcam();
} else if (host.includes("docs.abcam.com")) {
processDocsAbcam();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment