Skip to content

Instantly share code, notes, and snippets.

@theroux
Last active March 18, 2016 21:26
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 theroux/29724a356795bb215e3d to your computer and use it in GitHub Desktop.
Save theroux/29724a356795bb215e3d to your computer and use it in GitHub Desktop.
// ==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