aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/whatsapp/webview-unsafe.js
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/whatsapp/webview-unsafe.js')
-rw-r--r--recipes/whatsapp/webview-unsafe.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/recipes/whatsapp/webview-unsafe.js b/recipes/whatsapp/webview-unsafe.js
new file mode 100644
index 0000000..726014f
--- /dev/null
+++ b/recipes/whatsapp/webview-unsafe.js
@@ -0,0 +1,42 @@
1const PUSHSTATE_NORMAL = 0;
2const PUSHSTATE_THROTTLE = 1;
3const PUSHSTATE_DISABLE = 2;
4
5const PUSHSTATE_THROTTLE_THRESHOLD = 1;
6
7window.shPushState = window.history.pushState;
8//window.pushStateBehavior = PUSHSTATE_NORMAL;
9window.pushStateBehavior = PUSHSTATE_THROTTLE;
10window.pushStateCount = 0;
11
12function pushStateThrottled() {
13 if (window.pushStateCount < PUSHSTATE_THROTTLE_THRESHOLD)
14 {
15 window.shPushState.apply(window.history, arguments);
16 window.pushStateCount++;
17
18 if (window.pushStateCount == PUSHSTATE_THROTTLE_THRESHOLD)
19 setTimeout(() => {
20 window.pushStateCount = 0;
21 },
22 5000);
23 }
24 else
25 {
26 console.log("Pushstate temporarily blocked!");
27 }
28}
29
30function pushStateOneShot() {
31 window.shPushState.apply(window.history, arguments);
32
33 window.history.pushState = function() {};
34
35 console.log("Pushstate Disabled!");
36}
37
38if (window.pushStateBehavior != PUSHSTATE_NORMAL)
39{
40 window.history.pushState =
41 window.pushStateBehavior == PUSHSTATE_THROTTLE ? pushStateThrottled : pushStateOneShot;
42}