mirror of
https://github.com/jstrieb/urlpages.git
synced 2025-01-10 15:01:57 +01:00
Add absolute URL conversion to bookmarklet
Also add explanatory comments
This commit is contained in:
parent
f725e3e48d
commit
f3653f8bc7
2 changed files with 17 additions and 4 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -4,3 +4,6 @@
|
||||||
|
|
||||||
# Backed up copies of old files
|
# Backed up copies of old files
|
||||||
*.bak
|
*.bak
|
||||||
|
|
||||||
|
# Old HTML example files
|
||||||
|
*-old.html
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
(() => {
|
javascript:(() => {
|
||||||
|
/* Generate the b64 API functions */
|
||||||
var b64 = (() => {
|
var b64 = (() => {
|
||||||
function generateIndexDict(a) {
|
function generateIndexDict(a) {
|
||||||
let result = {};
|
let result = {};
|
||||||
|
@ -47,7 +48,7 @@
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
/* Generate the page -> base64 API functions */
|
||||||
var api = {
|
var api = {
|
||||||
VERSION: "0.2.0",
|
VERSION: "0.2.0",
|
||||||
|
|
||||||
|
@ -63,7 +64,16 @@
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Replace all relative URLs with absolute ones */
|
||||||
|
Array.from(document.querySelectorAll("[src],[href]")).map(l => {
|
||||||
|
if ("src" in l) {
|
||||||
|
l.src = (new URL(l.src, document.baseURI)).href;
|
||||||
|
} else if ("href" in l) {
|
||||||
|
l.href = (new URL(l.href, document.baseURI)).href;
|
||||||
|
}
|
||||||
|
return l;
|
||||||
|
});
|
||||||
|
|
||||||
javascript:window.open(api.getViewLink(document.documentElement.outerHTML), "_blank");
|
/* Redirect to the URL Page in a new tab */
|
||||||
|
window.open(api.getViewLink(document.documentElement.outerHTML), "_blank");
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in a new issue