diff options
-rw-r--r-- | recipes/whatsapp/package.json | 2 | ||||
-rw-r--r-- | recipes/whatsapp/webview-unsafe.js | 42 | ||||
-rw-r--r-- | recipes/whatsapp/webview.js | 3 |
3 files changed, 46 insertions, 1 deletions
diff --git a/recipes/whatsapp/package.json b/recipes/whatsapp/package.json index 5c70df9..3693582 100644 --- a/recipes/whatsapp/package.json +++ b/recipes/whatsapp/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "whatsapp", | 2 | "id": "whatsapp", |
3 | "name": "WhatsApp", | 3 | "name": "WhatsApp", |
4 | "version": "3.4.1", | 4 | "version": "3.4.2", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://web.whatsapp.com", | 7 | "serviceURL": "https://web.whatsapp.com", |
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 @@ | |||
1 | const PUSHSTATE_NORMAL = 0; | ||
2 | const PUSHSTATE_THROTTLE = 1; | ||
3 | const PUSHSTATE_DISABLE = 2; | ||
4 | |||
5 | const PUSHSTATE_THROTTLE_THRESHOLD = 1; | ||
6 | |||
7 | window.shPushState = window.history.pushState; | ||
8 | //window.pushStateBehavior = PUSHSTATE_NORMAL; | ||
9 | window.pushStateBehavior = PUSHSTATE_THROTTLE; | ||
10 | window.pushStateCount = 0; | ||
11 | |||
12 | function 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 | |||
30 | function pushStateOneShot() { | ||
31 | window.shPushState.apply(window.history, arguments); | ||
32 | |||
33 | window.history.pushState = function() {}; | ||
34 | |||
35 | console.log("Pushstate Disabled!"); | ||
36 | } | ||
37 | |||
38 | if (window.pushStateBehavior != PUSHSTATE_NORMAL) | ||
39 | { | ||
40 | window.history.pushState = | ||
41 | window.pushStateBehavior == PUSHSTATE_THROTTLE ? pushStateThrottled : pushStateOneShot; | ||
42 | } | ||
diff --git a/recipes/whatsapp/webview.js b/recipes/whatsapp/webview.js index 3586e14..180be79 100644 --- a/recipes/whatsapp/webview.js +++ b/recipes/whatsapp/webview.js | |||
@@ -36,6 +36,9 @@ module.exports = Ferdium => { | |||
36 | Ferdium.setBadge(count, indirectCount); | 36 | Ferdium.setBadge(count, indirectCount); |
37 | }; | 37 | }; |
38 | 38 | ||
39 | // inject webview hacking script | ||
40 | Ferdium.injectJSUnsafe(_path.default.join(__dirname, 'webview-unsafe.js')); | ||
41 | |||
39 | const getActiveDialogTitle = () => { | 42 | const getActiveDialogTitle = () => { |
40 | const element = document.querySelector('header .emoji-texttt'); | 43 | const element = document.querySelector('header .emoji-texttt'); |
41 | 44 | ||