diff options
-rw-r--r-- | recipes/whatsapp/package.json | 2 | ||||
-rw-r--r-- | recipes/whatsapp/service.css | 17 | ||||
-rw-r--r-- | recipes/whatsapp/webview.js | 40 |
3 files changed, 57 insertions, 2 deletions
diff --git a/recipes/whatsapp/package.json b/recipes/whatsapp/package.json index f476599..e2573dd 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.4", | 4 | "version": "3.4.5", |
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/service.css b/recipes/whatsapp/service.css index 0d4d5fc..667f618 100644 --- a/recipes/whatsapp/service.css +++ b/recipes/whatsapp/service.css | |||
@@ -15,4 +15,19 @@ | |||
15 | /* fix for blank spaces regarding view width on screens larger than 1080p */ | 15 | /* fix for blank spaces regarding view width on screens larger than 1080p */ |
16 | .app-wrapper-web ._1XkO3 { | 16 | .app-wrapper-web ._1XkO3 { |
17 | max-width: none !important; | 17 | max-width: none !important; |
18 | } \ No newline at end of file | 18 | } |
19 | |||
20 | /* Warning for trying to change theme on whatsapp */ | ||
21 | .ferdium-theme-message { | ||
22 | padding-top: 15px; | ||
23 | color: red; | ||
24 | line-height: 20px; | ||
25 | } | ||
26 | |||
27 | .ferdium-theme-title { | ||
28 | padding-top: 15px; | ||
29 | color: red; | ||
30 | line-height: 20px; | ||
31 | font-weight: bold; | ||
32 | text-align: center; | ||
33 | } | ||
diff --git a/recipes/whatsapp/webview.js b/recipes/whatsapp/webview.js index 77c4ebb..d0b0cd8 100644 --- a/recipes/whatsapp/webview.js +++ b/recipes/whatsapp/webview.js | |||
@@ -4,6 +4,45 @@ function _interopRequireDefault(obj) { | |||
4 | return obj && obj.__esModule ? obj : { default: obj }; | 4 | return obj && obj.__esModule ? obj : { default: obj }; |
5 | } | 5 | } |
6 | 6 | ||
7 | function createElement(messageBody, idString) { | ||
8 | const messageText = document.createTextNode(messageBody); | ||
9 | const message = document.createElement("p"); | ||
10 | message?.setAttribute("id", idString); | ||
11 | message?.setAttribute("class", idString); | ||
12 | message?.appendChild(messageText); | ||
13 | |||
14 | return message; | ||
15 | } | ||
16 | |||
17 | function addThemeMessage() { | ||
18 | const idString = 'ferdium-theme-message'; | ||
19 | const idStringTitle = 'ferdium-theme-title'; | ||
20 | const elementExists = document.querySelectorAll(`.${idString}`)[0] || document.querySelectorAll(`.${idStringTitle}`)[0] ? true : false; | ||
21 | |||
22 | if (!elementExists) { | ||
23 | const themePopupDiv = document.querySelectorAll("._2Nr6U")[0]; | ||
24 | |||
25 | // Create Ferdium Warning title element | ||
26 | const messageTitleString = 'FERDIUM WARNING!'; | ||
27 | const messageTitleElement = createElement(messageTitleString, idStringTitle); | ||
28 | |||
29 | // Create Ferdium Warning message element | ||
30 | const messageBody1 = 'To change your Whatsapp Theme, please use the native settings on Ferdium.'; | ||
31 | const messageBody2 = 'For that, right-click on the Whatsapp Service and click on Enable/Disable Dark mode.'; | ||
32 | const message1 = createElement(messageBody1, idString); | ||
33 | const message2 = createElement(messageBody2, idString); | ||
34 | |||
35 | // Add messages to Whatsapp Window | ||
36 | themePopupDiv?.prepend(message2) | ||
37 | themePopupDiv?.prepend(message1) | ||
38 | themePopupDiv?.prepend(messageTitleElement) | ||
39 | |||
40 | // Hide OK Button. | ||
41 | document.querySelectorAll("._20C5O")[1]?.setAttribute('style', 'display: none;'); | ||
42 | document.querySelectorAll("._2Nr6U > form")[0]?.setAttribute('style', 'display: none;'); | ||
43 | } | ||
44 | } | ||
45 | |||
7 | module.exports = Ferdium => { | 46 | module.exports = Ferdium => { |
8 | const getMessages = () => { | 47 | const getMessages = () => { |
9 | let count = 0; | 48 | let count = 0; |
@@ -48,6 +87,7 @@ module.exports = Ferdium => { | |||
48 | const loopFunc = () => { | 87 | const loopFunc = () => { |
49 | getMessages(); | 88 | getMessages(); |
50 | getActiveDialogTitle(); | 89 | getActiveDialogTitle(); |
90 | addThemeMessage(); | ||
51 | }; | 91 | }; |
52 | 92 | ||
53 | window.addEventListener('beforeunload', async () => { | 93 | window.addEventListener('beforeunload', async () => { |