Skip to content

Commit

Permalink
fix injection
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed May 20, 2024
1 parent d90395b commit ebd298b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
6 changes: 4 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "OldTweetDeck",
"description": "Returns old TweetDeck, for free!",
"version": "3.6.2",
"version": "3.6.4",
"manifest_version": 2,
"homepage_url": "https://github.com/dimdenGD/OldTweetDeck",
"permissions": [
"webRequest",
"webRequestBlocking",
"webNavigation",
"scripting",
"https://twitter.com/*",
"https://x.com/*",
"https://*.x.com/*",
Expand All @@ -29,9 +30,10 @@
},
"content_scripts": [
{
"matches": ["https://twitter.com/i/tweetdeck", "https://x.com/i/tweetdeck"],
"matches": ["https://twitter.com/i/tweetdeck", "https://x.com/i/tweetdeck", "https://x.com/i/tweetdeck?*"],
"js": ["src/notifications.js", "src/injection.js"],
"all_frames": true,
"world": "MAIN",
"run_at": "document_start"
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ chrome.webRequest.onHeadersReceived.addListener(
responseHeaders: headers
}
},
{urls: ["https://twitter.com/i/tweetdeck", "https://x.com/i/tweetdeck"]},
{urls: ["https://twitter.com/i/tweetdeck", "https://x.com/i/tweetdeck", "https://x.com/i/tweetdeck?*"]},
extraInfoSpec
);

Expand Down
20 changes: 20 additions & 0 deletions src/injection.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
let script = document.createElement('script');
script.innerHTML = `
Object.defineProperty(window, '__SCRIPTS_LOADED__', {
value: { main: true, vendor: true },
writable: false,
configurable: false
});
`;
if(document.head) {
document.head.appendChild(script);
} else {
let observer = new MutationObserver(() => {
if(document.head) {
document.head.appendChild(script);
observer.disconnect();
}
});
observer.observe(document.documentElement, { childList: true, subtree: true });
}

(async () => {
let html = await fetch(chrome.runtime.getURL('/files/index.html')).then(r => r.text());
document.documentElement.innerHTML = html;
Expand Down

0 comments on commit ebd298b

Please sign in to comment.