Skip to content

Instantly share code, notes, and snippets.

Created July 22, 2012 21:29
Show Gist options
  • Save anonymous/3161087 to your computer and use it in GitHub Desktop.
Save anonymous/3161087 to your computer and use it in GitHub Desktop.
LetsFreckle tag performance fix
// ==UserScript==
// @name LetsFreckle Tags
// @namespace http://www.lullabot.com/
// @version 0.1
// @description Reduce the number of tags to fix performance issues.
// @match https://*.letsfreckle.com/*
// @copyright 2012+, Andrew Berry, [email protected]
// ==/UserScript==
// Filter the list of tags.
function filterTags() {
exec(function() {
// Set this array to the list of tags you would like to use. Each tag be
// mapped to an existing tag, if it exists, so there is no need to specify
// tags by ID.
var myTags = ['yammer',
'irc',
'email',
'juno',
'ooyala'];
var filteredTags = [];
console.log(myTags);
for (i in freckleTags) {
tag = freckleTags[i];
if (myTags.indexOf(tag.name) >= 0) {
console.log(tag);
filteredTags.push(tag);
}
}
console.log(filteredTags);
window.freckleTags = filteredTags;
Freckle.Tags.set(filteredTags);
});
}
// We need this as we need to access the window object, which is restricted for
// for security reasons.
// http://stackoverflow.com/questions/5006460/userscripts-greasemonkey-calling-a-websites-javascript-functions
function exec(fn) {
var script = document.createElement('script');
script.setAttribute("type", "application/javascript");
script.textContent = '(' + fn + ')();';
document.body.appendChild(script); // run the script
document.body.removeChild(script); // clean up
}
filterTags();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment