Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function removeOrigin(dom) {
let origin = window.location.origin;
let $internalElements = dom.querySelectorAll(`[href^="${origin}"],[src^="${origin}"]`);
for (let $el of $internalElements) {
const attr = $el.hasAttribute('href') ? 'href' : 'src';
const value = $el.getAttribute(attr);
$el.setAttribute(attr, value.replace(origin, ''));
return dom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.