Skip to content

Instantly share code, notes, and snippets.

@gsabater
Last active April 2, 2023 14:56
Show Gist options
  • Save gsabater/d7767ee5d21069a814967ecfa81bd415 to your computer and use it in GitHub Desktop.
Save gsabater/d7767ee5d21069a814967ecfa81bd415 to your computer and use it in GitHub Desktop.
Userscript to clean Amazon links and remove Affiliate params
// ==UserScript==
// @name Amazon Affiliate cleaner
// @namespace https://gist.github.com/gsabater/d7767ee5d21069a814967ecfa81bd415
// @version 0.3
// @description Remove affiliate links for amazon links
// @author You
// @match *
// @include *
// @grant none
// ==/UserScript==
(function() {
'use strict';
function clearAmazonLinks(){
var links = document.getElementsByTagName("a");
for(var i=0; i<links.length; i++) {
var link = links[i];
if(link.href.includes("amazon.")){
var clean = link.href.substr(0, link.href.indexOf('?'));
// console.log(url,links[i].href);
link.href = clean;
}
}
}
window.setTimeout(clearAmazonLinks, 1000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment