forked from tanner/qotnews
15 lines
449 B
JavaScript
15 lines
449 B
JavaScript
|
(function () {
|
||
|
const { host, protocol } = window.location;
|
||
|
const url = `${protocol}//${host}`;
|
||
|
[
|
||
|
['[src^="/"]', 'src'],
|
||
|
['[href^="/"]', 'href']
|
||
|
].forEach(([selector, attribute]) => {
|
||
|
Array.from(document.querySelectorAll(selector))
|
||
|
.filter(e => e.attributes[attribute] && /^\/[^\/]/.test(e.attributes[attribute].value))
|
||
|
.forEach((e) => {
|
||
|
e.attributes[attribute].value = `${url}${e.attributes[attribute].value}`;
|
||
|
});
|
||
|
});
|
||
|
})();
|