Skip to content

Commit cb0b149

Browse files
committed
format relative path of img element to absolute path
1 parent d4e3bf2 commit cb0b149

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

AutoPatchWork.safariextension/includes/AutoPatchWork.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,11 @@
683683
return;
684684
}
685685
docs.forEach(function (doc, i, docs) {
686+
Array.prototype.forEach.call(doc.querySelectorAll('img'), function(img) {
687+
if (!img.getAttribute('src').test(/(^https?:\/\/|^data:|^\/)/)) {
688+
img.setAttribute('src', next.getAttribute('href').replace(/\/[\w:%#\$&\?\(\)~\.=\+\-]*$/, '/') + img.getAttribute('src'));
689+
}
690+
});
686691
var insert_node = append_point.insertBefore(document.importNode(doc, true), insert_point);
687692
var mutation = {
688693
targetNode: insert_node,

0 commit comments

Comments
 (0)