Skip to content

Commit

Permalink
make it work with oldtweetdeck
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed Aug 19, 2023
1 parent 86bfa68 commit ad04b57
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 38 deletions.
15 changes: 1 addition & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,4 @@ jobs:
- run: npm ci

- name: Typecheck + lint
run: npm test

# Runs a set of commands using the runners shell
- name: Publish unlisted addon to AMO
env:
FIREFOX_BETA_ID: ${{ secrets.FIREFOX_BETA_ID }}
AMO_API_KEY: ${{ secrets.AMO_API_KEY }}
AMO_API_SECRET: ${{ secrets.AMO_API_SECRET }}
NIGHTLY_DISCORD_WEBHOOK_TOKEN: ${{ secrets.NIGHTLY_DISCORD_WEBHOOK_TOKEN }}
NIGHTLY_DISCORD_WEBHOOK_ID: ${{ secrets.NIGHTLY_DISCORD_WEBHOOK_ID }}
NIGHTLY_DISCORD_ROLE_ID: ${{ secrets.NIGHTLY_DISCORD_ROLE_ID }}
NIGHTLY_TENOR_API_KEY: ${{ secrets.NIGHTLY_TENOR_API_KEY }}
NIGHTLY_GIPHY_API_KEY: ${{ secrets.NIGHTLY_GIPHY_API_KEY }}
run: npm run build:firefox-beta && npx web-ext sign --api-key="$AMO_API_KEY" --api-secret="$AMO_API_SECRET" -s dist --channel unlisted && npm run ts-node -- tools/uploadNightly.ts
run: npm test
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

<h1 align="center">Better TweetDeck</h1>

# Intro

**As of July 4th 2023, [Old TweetDeck has been unplugged, Preview is the way and will require a Verification](https://twitter.com/TwitterSupport/status/1675990712297443330). This project is thus over. Thank you for the support over the years.**
This fork works with [OldTweetDeck](/~https://github.com/dimdenGD/OldTweetDeck)! Install the same way as you did with OldTweetDeck except get archive from [Releases page](/~https://github.com/dimdenGD/BetterTweetDeck/releases).
6 changes: 3 additions & 3 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ browser.storage.onChanged.addListener(async (changes) => {
});

browser.runtime.onMessage.addListener(async (request: BTDMessageEvent, sender) => {
if (sender.url !== 'https://tweetdeck.twitter.com/') {
throw new Error('Message not coming from BTD');
}
// if (sender.url !== 'https://tweetdeck.twitter.com/') {
// throw new Error('Message not coming from BTD');
// }

switch (request.data.name) {
case BTDMessages.OPEN_SETTINGS: {
Expand Down
21 changes: 10 additions & 11 deletions src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,21 @@ import {sendMessageToBackground} from './helpers/webExtensionHelpers';
import {processDownloadMediaRequest} from './services/backgroundGifRequests';
import {getValidatedSettings} from './services/backgroundSettings';
import {injectInTD} from './services/injectInTD';
import {rollbackToLegacy} from './services/rollbackToLegacy';
import {setupBTDNotifications} from './services/setupBTDNotifications';
import {setupBtdRoot} from './services/setupBTDRoot';
import {BTDMessageOriginsEnum, BTDMessages} from './types/btdMessageTypes';

(async () => {
const hasNewTweetDeck = document.querySelectorAll('script[src*="tweetdeck-web"]').length === 0;

if (hasNewTweetDeck) {
console.debug('Better TweetDeck aborted loading on TweetDeck Preview');
if (localStorage.getItem('STOP_ROLLBACK_TO_LEGACY') === 'true') {
return;
}
rollbackToLegacy();
return;
}
// const hasNewTweetDeck = document.querySelectorAll('script[src*="tweetdeck-web"]').length === 0;

// if (hasNewTweetDeck) {
// console.debug('Better TweetDeck aborted loading on TweetDeck Preview');
// if (localStorage.getItem('STOP_ROLLBACK_TO_LEGACY') === 'true') {
// return;
// }
// rollbackToLegacy();
// return;
// }

// Inject some scripts.
injectInTD();
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/communicationHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const ORIGIN_BETTER_TW = 'https://better.tw';

export function isMessageEventAllowed(ev: MessageEvent) {
const {origin, data} = ev;
const allowedOrigins = [ORIGIN_TWEETDECK, ORIGIN_BETTER_TW];
const allowedOrigins = [ORIGIN_TWEETDECK, ORIGIN_BETTER_TW, 'https://tweetdeck.dimden.dev'];

if (!allowedOrigins.includes(origin)) {
return false;
Expand Down Expand Up @@ -74,7 +74,7 @@ export function listenToInternalBTDMessage(
requestId: data.requestId,
isReponse: true,
} as BTDMessageEventData,
ORIGIN_TWEETDECK
'*'
);
};

Expand Down Expand Up @@ -114,7 +114,7 @@ export function sendInternalBTDMessage(msg: Omit<BTDMessageEventData, 'requestId
...msg,
requestId,
} as BTDMessageEventData,
ORIGIN_TWEETDECK
'*'
);
});
}
4 changes: 2 additions & 2 deletions tools/manifests/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ module.exports = {
web_accessible_resources: [
{
resources: common.web_accessible_resources,
matches: ['*://tweetdeck.twitter.com/*'],
matches: ['*://tweetdeck.twitter.com/*', '*://tweetdeck.dimden.dev/*'],
},
],
externally_connectable: {
matches: ['*://tweetdeck.twitter.com/*'],
matches: ['*://tweetdeck.twitter.com/*', '*://tweetdeck.dimden.dev/*'],
},
browser_action: undefined,
action: undefined,
Expand Down
3 changes: 2 additions & 1 deletion tools/manifests/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ module.exports = {
icons,
content_scripts: [
{
matches: ['*://tweetdeck.twitter.com/*'],
matches: ['*://tweetdeck.twitter.com/*', '*://tweetdeck.dimden.dev/*'],
js: ['build/content.js'],
run_at: 'document_end',
all_frames: true,
},
],
background: {
Expand Down
6 changes: 5 additions & 1 deletion tools/manifests/commonHosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ const commonConnectHosts = (exports.commonConnectHosts = [
'https://*.twimg.com',
]);

exports.commonHosts = ['*://tweetdeck.twitter.com/*', ...commonConnectHosts.map((h) => `${h}/*`)];
exports.commonHosts = [
'*://tweetdeck.twitter.com/*',
'*://tweetdeck.dimden.dev/*',
...commonConnectHosts.map((h) => `${h}/*`),
];

0 comments on commit ad04b57

Please sign in to comment.