Skip to content

Instantly share code, notes, and snippets.

@nitinthewiz
Last active December 20, 2015 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nitinthewiz/6124115 to your computer and use it in GitHub Desktop.
Save nitinthewiz/6124115 to your computer and use it in GitHub Desktop.
App.net Everywhere. This script will tell every website that you've come from App.net... It's a good way to spread the word about ADN. Install TamperMonkey on Chrome and add this script.
// ==UserScript==
// @name App.net Everywhere
// @namespace nitinkhanna.com
// @description Tells all websites about a UTM campaign called App.net
// @match http://*/*
// @match https://*/*
// @exclude http://*treeview*
// @exclude https://*alpha.app.net*
// @grant none
// @run-at document-start
// @version 0.1
// ==/UserScript==
function addtoURL(myRegEx0,mySubstr,myURL) {
// Mogrify the current URL
var myRegEx1 = /\?/g;
if (!myRegEx0.test(myURL)) {
// There might already be some parameters in the URL
if (myRegEx1.test(myURL)) {
window.location.href = myURL + "&" + mySubstr;
}
else {
window.location.href = myURL + "?" + mySubstr;
}
}
}
window.addEventListener("load", function () {
// Let's figure out the current page
var myDomain = window.location.hostname;
var myDomainElements = myDomain.split(".");
// Yes, I know it's ugly
var mySLD = myDomainElements[myDomainElements.length - 2] + "." + myDomainElements[myDomainElements.length - 1];
var myURL = window.location.href;
console.log(myURL);
addtoURL(/(\?|\&)utm_medium=App.net&utm_source=PourOver/g,"utm_medium=App.net&utm_source=PourOver",myURL);
},
false
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment