Skip to content

Instantly share code, notes, and snippets.

@julescarbon
Created October 16, 2012 17:29
Show Gist options
  • Save julescarbon/3900730 to your computer and use it in GitHub Desktop.
Save julescarbon/3900730 to your computer and use it in GitHub Desktop.
bookmarklet: strip commas #textmeme
javascript:(function () {
function getTextNodesIn(node, includeWhitespaceNodes) {
var textNodes = [], whitespace = /^\s*$/;
function getTextNodes(node) {
if (node.nodeType == 3) {
if (includeWhitespaceNodes || !whitespace.test(node.nodeValue)) {
textNodes.push(node);
}
} else {
for (var i = 0, len = node.childNodes.length; i < len; ++i) {
getTextNodes(node.childNodes[i]);
}
}
}
getTextNodes(node);
return textNodes;
}
var textNodes = getTextNodesIn(document.body);
var punctuation = /,/g;
for (var i = 0, len = textNodes.length; i < len; i++) {
textNodes[i].textContent = textNodes[i].textContent.replace(punctuation,"");
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment