diff options
| author | Arpit Chakladar <arpitchakladar+git@gmail.com> | 2026-07-13 20:49:57 +0530 |
|---|---|---|
| committer | Arpit Chakladar <arpitchakladar+git@gmail.com> | 2026-07-13 20:49:57 +0530 |
| commit | 6f6c263a072c9df4e826d8ebb2035c82a87be7e0 (patch) | |
| tree | c8b944fe53b660d9d58b5559b10f4c73141e7559 /src/scripts/common/stop-blocking.ts | |
| parent | bc4eb3606afbbc4b54fbb3b4ef81badd06cde525 (diff) | |
| download | banglar-bhumi-utils-6f6c263a072c9df4e826d8ebb2035c82a87be7e0.tar.gz banglar-bhumi-utils-6f6c263a072c9df4e826d8ebb2035c82a87be7e0.zip | |
refactor: organised the scripts into a more well defined structure
now all scripts that are common to all pages lie in src/scripts/common
each page gets its own folder in src/pages and different parts of the
page's configuration are separated in separated folders which are all
finally imported in src/pages/*/index.ts
Diffstat (limited to 'src/scripts/common/stop-blocking.ts')
| -rw-r--r-- | src/scripts/common/stop-blocking.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/scripts/common/stop-blocking.ts b/src/scripts/common/stop-blocking.ts new file mode 100644 index 0000000..3fa3de6 --- /dev/null +++ b/src/scripts/common/stop-blocking.ts @@ -0,0 +1,29 @@ +/** + * Proxies jQuery's `.bind()` (for the `"cut copy paste"` event) and + * `.keydown()` so that the website's copy/paste/right-click blocking + * is disabled. Reverts the prototypes after patching to avoid + * interfering with other code. + */ +document.addEventListener("DOMContentLoaded", () => { + const proxiedBind = $.prototype.bind; + /** Proxies jQuery `.bind()` to no-op the `"cut copy paste"` event. */ + $.prototype.bind = function() { + if (arguments[0].trim() === "cut copy paste") { + arguments[1] = (_: any) => {}; + } + + return proxiedBind.apply(this, Array.from(arguments) as any); + } + + const proxiedKeydown = $.prototype.keydown; + /** Proxies jQuery `.keydown()` so all key presses are allowed. */ + $.prototype.keydown = function() { + arguments[0] = (_: any) => true; + + return proxiedKeydown.apply(this, Array.from(arguments) as any); + } + + $.prototype.bind = proxiedBind; + $.prototype.keydown = proxiedKeydown; + document.oncontextmenu = () => true; +}); |
