Created
February 25, 2017 21:30
-
-
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//"
This file contains 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
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