mirror of
https://github.com/D4Vinci/Scrapling.git
synced 2026-11-21 02:44:16 +08:00
- Changed the structure to make it easier to add others soon. - Moved the sponsors to a shared template between languages.
14 lines
669 B
JavaScript
14 lines
669 B
JavaScript
(() => {
|
|
const base = new URL(JSON.parse(document.getElementById("__config").textContent).base, location);
|
|
if (!base.pathname.endsWith("/")) base.pathname += "/";
|
|
const links = [...document.querySelectorAll(".md-select a[hreflang]")].map(link => [link, link.href]);
|
|
const update = () => links.forEach(([link, root]) => {
|
|
link.href = new URL(location.pathname.slice(base.pathname.length) + location.search + location.hash, root).href;
|
|
link.target = "_self";
|
|
});
|
|
update();
|
|
location$.subscribe(update);
|
|
addEventListener("hashchange", update);
|
|
for (const event of ["click", "auxclick", "contextmenu"]) addEventListener(event, update, true);
|
|
})();
|