Last active
March 18, 2016 21:26
-
-
Save theroux/29724a356795bb215e3d to your computer and use it in GitHub Desktop.
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
// ==UserScript== | |
// @name One Creative | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Intelligently auto-shows/hides search box and filters | |
// @author Andrew Theroux | |
// @match http://onecreative.aol.com/ | |
// @grant none | |
// ==/UserScript== | |
/* jshint -W097 */ | |
'use strict'; | |
// Your code here... | |
window.addEventListener('load', getHashValue, false); | |
window.addEventListener('hashchange', getHashValue, false); | |
function getHashValue() { | |
var hash = window.location.hash.replace(/^#/, '').split(':')[0], | |
topPages = ['ads', 'campaigns', 'templates'], | |
clearClasses = function() { | |
topPages.map(function(page) { | |
document.body.classList.remove(page); | |
}); | |
}; | |
if (topPages.indexOf(hash) != -1 ) { | |
clearClasses(); | |
document.body.classList.add(hash); | |
} | |
else { | |
clearClasses(); | |
} | |
//console.log('new hash is ' + hash); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment