Created
May 22, 2024 17:01
-
-
Save bryan-lunt/b7ec6abe922605f3f82ead1fc99dd3eb to your computer and use it in GitHub Desktop.
Prevent Lost work on DataAnnotation.tech
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Disable Back Button | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Disables the back button for specified URLs | |
// @author You | |
// @match https://app.dataannotation.tech/workers/tasks/* | |
// @grant none | |
// ==/UserScript== | |
// Replace "your-target-website-url-here" with the actual URLs you want to target | |
// | |
// Copied from StackOverflow https://stackoverflow.com/a/12381873 | |
// | |
(function (global) { | |
if(typeof (global) === "undefined") { | |
throw new Error("window is undefined"); | |
} | |
var _hash = "!"; | |
var noBackPlease = function () { | |
global.location.href += "#"; | |
// Making sure we have the fruit available for juice (^__^) | |
global.setTimeout(function () { | |
global.location.href += "!"; | |
}, 50); | |
}; | |
global.onhashchange = function () { | |
if (global.location.hash !== _hash) { | |
global.location.hash = _hash; | |
} | |
}; | |
global.onload = function () { | |
noBackPlease(); | |
// Disables backspace on page except on input fields and textarea.. | |
document.body.onkeydown = function (e) { | |
var elm = e.target.nodeName.toLowerCase(); | |
if (e.which === 8 && (elm !== 'input' && elm !== 'textarea')) { | |
e.preventDefault(); | |
} | |
// Stopping the event bubbling up the DOM tree... | |
e.stopPropagation(); | |
}; | |
} | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prevents losing work on DataAnnotation dashboard.