Last active
January 17, 2019 13:50
-
-
Save zaverden/149945f5a9fb2cbdb7048402ef9b485b to your computer and use it in GitHub Desktop.
demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <script> | |
| (function (paramName, url) { | |
| function hrefWithoutHash(anchor) { | |
| var hashLength = anchor.hash.length; | |
| return anchor.href.substring(0, anchor.href.length - hashLength); | |
| } | |
| function addValue(anchor, value) { | |
| var separator = anchor.href.indexOf('?') < 0 ? '?' : '&'; | |
| anchor.href = hrefWithoutHash(anchor) + | |
| separator + | |
| encodeURIComponent(paramName) + '=' + encodeURIComponent(value) + | |
| anchor.hash; | |
| } | |
| function getRandomValue(list) { | |
| var randIndex = Math.floor(Math.random() * list.length); | |
| return list[randIndex]; | |
| } | |
| function loadList() { | |
| return fetch(url, { redirect: 'follow' }) | |
| .then(function (resp) { return resp.json(); }) | |
| .catch(function () { /* just ignore errors */ }) | |
| } | |
| window.onload = function onload() { | |
| loadList(). | |
| then(function (list) { | |
| if (!list) return; | |
| Array.from(document.getElementsByTagName('a')) | |
| .filter(a => a.href && a.href !== '#') | |
| .forEach(a => addValue(a, getRandomValue(list))) | |
| }); | |
| } | |
| })( | |
| 'variable2', | |
| 'https://gist.githubusercontent.com/zaverden/f20e341a6f1e42cb7e6a0b6e23a60451/raw/3a01d3aca0ef8f4152a9044d813d7006ed51ea34/list.json' | |
| ); | |
| </script> | |
| </head> | |
| <body> | |
| <a href="http://www.trackinglink.com/?variable1=1">Link 1</a> | |
| <a href="http://www.trackinglink.com/">Link 2</a> | |
| <a href="http://www.trackinglink.com/dir/?asd=wer#sad=fddd">Link 3</a> | |
| <a href="/vendor/?variable1=1">Link 4</a> | |
| <a href="/vendor">Link 5</a> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| (function (paramName, url) { | |
| function hrefWithoutHash(anchor) { | |
| var hashLength = anchor.hash.length; | |
| return anchor.href.substring(0, anchor.href.length - hashLength); | |
| } | |
| function addValue(anchor, value) { | |
| var separator = anchor.href.indexOf('?') < 0 ? '?' : '&'; | |
| anchor.href = hrefWithoutHash(anchor) + | |
| separator + | |
| encodeURIComponent(paramName) + '=' + encodeURIComponent(value) + | |
| anchor.hash; | |
| } | |
| function getRandomValue(list) { | |
| var randIndex = Math.floor(Math.random() * list.length); | |
| return list[randIndex]; | |
| } | |
| function loadList() { | |
| return fetch(url, { redirect: 'follow' }) | |
| .then(function (resp) { return resp.json(); }) | |
| .catch(function () { /* just ignore errors */ }) | |
| } | |
| window.onload = function onload() { | |
| loadList(). | |
| then(function (list) { | |
| if (!list) return; | |
| Array.from(document.getElementsByTagName('a')) | |
| .filter(a => a.href && a.href !== '#') | |
| .forEach(a => addValue(a, getRandomValue(list))) | |
| }); | |
| } | |
| })( | |
| 'variable2', | |
| 'https://gist.githubusercontent.com/zaverden/f20e341a6f1e42cb7e6a0b6e23a60451/raw/3a01d3aca0ef8f4152a9044d813d7006ed51ea34/list.json' | |
| ); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment