Skip to content

Instantly share code, notes, and snippets.

@murrayinman
Created July 21, 2023 01:31
Show Gist options
  • Save murrayinman/d897f6aa281e67d967ca5aa2f25cfb87 to your computer and use it in GitHub Desktop.
Save murrayinman/d897f6aa281e67d967ca5aa2f25cfb87 to your computer and use it in GitHub Desktop.
This will search the page for `https\://` and strip the `\` character from image src attributes.
(function() {
var imgElements = document.getElementsByTagName('img');
for (var i = 0; i < imgElements.length; i++) {
var src = imgElements[i].getAttribute('src');
var modifiedSrc = src.replace(/https\\:/g, 'https:');
imgElements[i].setAttribute('src', modifiedSrc);
}
console.log('Image URLs fixed!');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment