diff options
author | André Oliveira <37463445+SpecialAro@users.noreply.github.com> | 2022-08-06 14:10:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-06 14:10:53 +0100 |
commit | 6b2bc506c212e88359f06107097ac4446bd5216f (patch) | |
tree | 86b0910dd62656364251296fb7ae803c28e949c4 /recipes/whatsapp/webview.js | |
parent | docs: add DavidUser as a contributor for code (#141) (diff) | |
download | ferdium-recipes-6b2bc506c212e88359f06107097ac4446bd5216f.tar.gz ferdium-recipes-6b2bc506c212e88359f06107097ac4446bd5216f.tar.zst ferdium-recipes-6b2bc506c212e88359f06107097ac4446bd5216f.zip |
fix: add warning to whatsapp theming (#138)
* fix: add warning to whatsapp theming
* fix: typo
Diffstat (limited to 'recipes/whatsapp/webview.js')
-rw-r--r-- | recipes/whatsapp/webview.js | 40 |
1 files changed, 40 insertions, 0 deletions
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 () => { |