Spaces:
Running
Running
File size: 1,210 Bytes
39dcf3b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
// (function () {
// const allowedOrigin = window.location.origin;
// const originalAssign = window.location.assign;
// const originalReplace = window.location.replace;
// function isAllowed(url) {
// try {
// const u = new URL(url, window.location.href);
// return u.origin === allowedOrigin;
// } catch (e) {
// return false;
// }
// }
// window.location.assign = function (url) {
// if (isAllowed(url)) {
// originalAssign.call(window.location, url);
// } else {
// console.warn("Blocked redirect to:", url);
// }
// };
// window.location.replace = function (url) {
// if (isAllowed(url)) {
// originalReplace.call(window.location, url);
// } else {
// console.warn("Blocked redirect to:", url);
// }
// };
// })();
let lastSafeURL = location.href;
setInterval(() => {
if (location.href !== lastSafeURL) {
const newURL = new URL(location.href);
if (newURL.origin !== location.origin) {
console.warn("Redirect blocked:", location.href);
history.pushState(null, "", lastSafeURL);
} else {
lastSafeURL = location.href;
}
}
}, 50); |