Skip to content

Commit

Permalink
Made WebSocketInterception.js load faster to workaround a race bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tomer8007 committed Jul 30, 2019
1 parent ef57d0e commit 7fe2674
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion core_injection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ inject();

async function inject()
{
await addScript('core/WebScoketInterception.js');
await addScriptInstantly('core/WebScoketInterception.js');
await addScript('core/BinaryReader.js');
await addScript('core/WAPacket.js');
await addScript('core/Crypto.js');
Expand All @@ -14,6 +14,21 @@ async function inject()
await addScript('core/Main.js');
}

async function addScriptInstantly(scriptName)
{
fetch(chrome.extension.getURL(scriptName))
.then((response) =>
{
response.body.getReader().read().then((text) =>
{
var s = document.createElement('script');
s.textContent = new TextDecoder("utf-8").decode(text.value);
(document.head||document.documentElement).appendChild(s);
});
});
}


function addScript(scriptName) {
return new Promise(function(resolve, reject) {
var s = document.createElement('script');
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "WAIncognito",
"short_name": "WhatsIncognito",
"description": "Be invisible on WhatsApp™ Web by disabling read receipts and presence updates",
"version": "1.4.5",
"version": "1.4.6",
"permissions": [ ],
"icons":
{
Expand Down

2 comments on commit 7fe2674

@cardinal2019
Copy link

@cardinal2019 cardinal2019 commented on 7fe2674 Aug 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the manifest.jason on mine is, what should I change or add please. I don't know much about it... thanks

{
"background": {
"persistent": true,
"scripts": [ "background.js" ]
},
"browser_action": {
"default_icon": "images/icon_128_reshaped.png"
},
"content_scripts": [ {
"js": [ "core_injection.js" ],
"matches": [ "https://web.whatsapp.com/" ],
"run_at": "document_start"
}, {
"css": [ "styles.css", "lib/drop/css/drop-theme-basic.css", "lib/sweetalert/sweetalert.css" ],
"js": [ "core/UI.js", "lib/drop/drop.js", "lib/sweetalert/sweetalert.min.js" ],
"matches": [ "https://web.whatsapp.com/
" ]
} ],
"description": "Be invisible on WhatsApp™ Web by disabling read receipts and presence updates",
"icons": {
"128": "images/icon_128_blue.png"
},
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAl/qqpAM16NHOATA73ywCB+cXILR0ZORVZuUGCYdH4mXHH5y6FCgoc+7PtE7RaF3F1RLdoBl4LrgstmFAJaKBTR0il6Zrh60WuMAiyEnBhr8+OdP4vEhn1jbZpQYPes/jtXYWH85tyuckNjJ3WEqDZGyDzvbxTLdzmb9VTKen0DADXrbjd7e2ykfuGZ8Bex39TjEq/kwYzaGbLnyDaKc5A+Qv0xF55akEe10gHMRveaGKbBks5YgUBaURSluweoYzysO7s291Ev1lZhIPE/Jpe8Sl/xBN3DptjgBP33mnJ2RtSdQ7pAuZk1ASBlW7Dysr5s3zGdPQkwDMuaY3kUaM9QIDAQAB",
"manifest_version": 2,
"name": "WAIncognito",
"permissions": [ ],
"short_name": "WhatsIncognito",
"update_url": "https://clients2.google.com/service/update2/crx",
"version": "1.4.6",
"web_accessible_resources": [ "lib/drop/drop.js", "lib/sweetalert/sweetalert.min.js", "core/", "images/" ]
}

@tomer8007
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your manifest.json is what is should be, apparently the bug still exists for some users.

Please sign in to comment.