Skip to content

Instantly share code, notes, and snippets.

@kellylougheed
Created February 25, 2017 21:30
Show Gist options
  • Save kellylougheed/1c8429dc9fee31567a0032535d9b97ca to your computer and use it in GitHub Desktop.
Save kellylougheed/1c8429dc9fee31567a0032535d9b97ca to your computer and use it in GitHub Desktop.
JS for a friend's SquareSpace page to clean up titles beginning with "Category//"
window.onload = function() {
cleanTitles();
function cleanTitles() {
var arr = document.getElementsByClassName("index-item-title-text");
for (var i = 0; i < arr.length; i++) {
var element = arr[i];
element.innerText = stripCategory(element.innerText);
}
}
function stripCategory(str) {
var index = str.indexOf("//");
if (index !== -1) {
index = index + 2;
str = str.slice(index, str.length);
}
return str;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment