Skip to content

Instantly share code, notes, and snippets.

@Shilo
Created February 11, 2019 03:07
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 Shilo/62337e724048a14c90491f10aa124f38 to your computer and use it in GitHub Desktop.
Save Shilo/62337e724048a14c90491f10aa124f38 to your computer and use it in GitHub Desktop.
Javascript snippit to hide/censor price tags on a website. (Note: seems to break interaction with the site, use at own risk)
(function(context) {
var priceCensor = "X.XX";
var pattern=/(\$)(\d([\d\,\.]+)?)/g,
callback=function(_,dollar,price) {
price=price.replace(/,/g,'');
return dollar + price;
},
html = context.innerHTML.replace(pattern,callback);
context.innerHTML = html;
})(document.body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment