2024-08-27 22:55:45 +02:00
|
|
|
(function(){
|
|
|
|
|
|
|
|
if (location.protocol !== 'file:') {
|
2024-08-31 00:58:33 +02:00
|
|
|
window.PatchLocalFileAnchor = Void;
|
2024-08-27 22:55:45 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-08-31 00:58:33 +02:00
|
|
|
window.PatchLocalFileAnchor = (function PatchLocalFileAnchor (anchorEl) {
|
|
|
|
var href = anchorEl.href;
|
|
|
|
if (href.startsWith('file://')) {
|
|
|
|
var tokens = href.split('#');
|
|
|
|
href = tokens[0];
|
|
|
|
if (href.endsWith('/')) {
|
|
|
|
href += 'index.html';
|
2024-08-27 22:55:45 +02:00
|
|
|
}
|
2024-08-31 00:58:33 +02:00
|
|
|
tokens = tokens.slice(1);
|
|
|
|
if (tokens.length) {
|
|
|
|
href += ('#' + tokens.join('#'));
|
|
|
|
}
|
|
|
|
anchorEl.href = href;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
window.addEventListener('DOMContentLoaded', (function(){
|
|
|
|
Array.from(document.querySelectorAll('a[href]')).forEach(PatchLocalFileAnchor);
|
2024-08-27 22:55:45 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
})();
|