Skip to content

Commit

Permalink
fix x.com
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed May 17, 2024
1 parent ef5f22f commit 8ba2d21
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
10 changes: 5 additions & 5 deletions files/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function expandTweet(e, tweet_id) {
e.target.onclick = null;

var xhr = new XMLHttpRequest();
xhr.open("GET", `https://api.twitter.com/1.1/statuses/show/${tweet_id}.json`, true);
xhr.open("GET", `https://api.${location.hostname}/1.1/statuses/show/${tweet_id}.json`, true);
xhr.setRequestHeader("X-Twitter-Active-User", "yes");
xhr.setRequestHeader("X-Twitter-Auth-Type", "OAuth2Session");
xhr.setRequestHeader("X-Twitter-Client-Language", "en");
Expand Down Expand Up @@ -48,7 +48,7 @@ function expandTweet(e, tweet_id) {
function follow(screen_name) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open("POST", `https://api.twitter.com/1.1/friendships/create.json`, true);
xhr.open("POST", `https://api.${location.hostname}/1.1/friendships/create.json`, true);
xhr.setRequestHeader("X-Twitter-Active-User", "yes");
xhr.setRequestHeader("X-Twitter-Auth-Type", "OAuth2Session");
xhr.setRequestHeader("X-Twitter-Client-Language", "en");
Expand Down Expand Up @@ -82,7 +82,7 @@ document.body.addEventListener("click", function (e) {
var xhr = new XMLHttpRequest();
xhr.open(
"POST",
`https://twitter.com/i/api/graphql/aoDbu3RHznuiSkQ9aNM67Q/CreateBookmark`,
`https://${location.hostname}/i/api/graphql/aoDbu3RHznuiSkQ9aNM67Q/CreateBookmark`,
true
);
xhr.setRequestHeader("X-Twitter-Active-User", "yes");
Expand Down Expand Up @@ -8985,10 +8985,10 @@ document.body.addEventListener("click", function (e) {
minimum_version: "4.0.190610153508",
web_root: "https://tweetdeck.twitter.com",
api_root: "https://tweetdeck.twitter.com",
twitter_api_base: "https://api.twitter.com",
twitter_api_base: `https://api.${location.hostname}`,
twitter_api_version: "1.1",
twitter_stream_base: "https://userstream.twitter.com",
twitter_upload_base: "https://upload.twitter.com",
twitter_upload_base: `https://upload.${location.hostname}`,
td_create_key: "WRaMQNHU2Jy51bhFEL3C",
td_create_secret: "MiLkmD1t1xlZqKoLLY8ScxX5gwpOQsjBopZcV4KLcuo=",
// bearer_token: "AAAAAAAAAAAAAAAAAAAAAF7aAAAAAAAASCiRjWvh7R5wxaKkFp7MM%2BhYBqM%3DbQ0JPmjU9F6ZoMhDfI4uTNAaQuTDm2uO9x3WFVr2xBZ2nhjdP0",
Expand Down
6 changes: 4 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"name": "OldTweetDeck",
"description": "Returns old TweetDeck, for free!",
"version": "3.5.6",
"version": "3.6.0",
"manifest_version": 2,
"homepage_url": "https://github.com/dimdenGD/OldTweetDeck",
"permissions": [
"webRequest",
"webRequestBlocking",
"webNavigation",
"https://twitter.com/*",
"https://x.com/*",
"https://*.x.com/*",
"https://tweetdeck.twitter.com/*",
"https://abs.twimg.com/*",
"https://api.twitter.com/*",
Expand All @@ -27,7 +29,7 @@
},
"content_scripts": [
{
"matches": ["https://twitter.com/i/tweetdeck"],
"matches": ["https://twitter.com/i/tweetdeck", "https://x.com/i/tweetdeck"],
"js": ["src/notifications.js", "src/injection.js"],
"all_frames": true,
"run_at": "document_start"
Expand Down
18 changes: 8 additions & 10 deletions 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"]},
{urls: ["https://twitter.com/i/tweetdeck", "https://x.com/i/tweetdeck"]},
extraInfoSpec
);

Expand All @@ -21,7 +21,7 @@ chrome.webRequest.onBeforeSendHeaders.addListener(
requestHeaders: headers
}
},
{urls: ["https://twitter.com/i/api/graphql/*"]},
{urls: ["https://twitter.com/i/api/graphql/*", "https://x.com/i/api/graphql/*"]},
extraInfoSpec.map(s => s.replace('response', 'request'))
)

Expand All @@ -41,7 +41,7 @@ chrome.webRequest.onBeforeRequest.addListener(
};
} catch(e) {}
},
{urls: ["https://*.twitter.com/*"]},
{urls: ["https://*.twitter.com/*", "https://*.x.com/*"]},
["blocking"]
);

Expand All @@ -51,7 +51,7 @@ chrome.webRequest.onBeforeRequest.addListener(
redirectUrl: 'https://twitter.com/i/tweetdeck'
}
},
{urls: ["https://tweetdeck.twitter.com/*"]},
{urls: ["https://tweetdeck.twitter.com/*", "https://tweetdeck.x.com/*"]},
["blocking"]
);

Expand Down Expand Up @@ -79,11 +79,9 @@ chrome.webNavigation.onCommitted.addListener(
// Only needed in Chrome. See: https://developer.chrome.com/docs/extensions/reference/webRequest/#caching
if (
!isFirefox &&
urls[details.tabId]?.[details.frameId].startsWith(
"https://twitter.com/",
) &&
(urls[details.tabId]?.[details.frameId].startsWith("https://twitter.com/") || urls[details.tabId]?.[details.frameId].startsWith("https://x.com/")) &&
details.transitionType !== "reload" &&
details.url === "https://twitter.com/i/tweetdeck"
(details.url === "https://twitter.com/i/tweetdeck" || details.url === "https://x.com/i/tweetdeck")
) {
flushCache();
// Update stored URL
Expand All @@ -96,7 +94,7 @@ chrome.webNavigation.onCommitted.addListener(
}
urls[details.tabId][details.frameId] = details.url;
},
{ url: [{ hostSuffix: "twitter.com" }] },
{ url: [{ hostSuffix: "twitter.com" }, { hostSuffix: "x.com" }] },
);

// Block requests for files related to Web App, except for main.{random}.js (which may be needed for API connection)
Expand All @@ -112,7 +110,7 @@ chrome.webRequest.onBeforeRequest.addListener(
path.startsWith("/responsive-web/client-web-legacy/") ||
path.startsWith("/responsive-web/client-web/")
) &&
requestFrom === "https://twitter.com/i/tweetdeck" &&
(requestFrom === "https://twitter.com/i/tweetdeck" || requestFrom === "https://x.com/i/tweetdeck") &&
!path.includes('ondemand.s.')
) {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ window.addEventListener('message', e => {
}
}

let homepageData = await fetch('https://twitter.com/').then(res => res.text());
let homepageData = await fetch(`https://${location.hostname}/`).then(res => res.text());
let dom = new DOMParser().parseFromString(homepageData, 'text/html');
let anims = Array.from(dom.querySelectorAll('svg[id^="loading-x"]')).map(svg => svg.outerHTML);

Expand Down
12 changes: 6 additions & 6 deletions src/interception.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function cleanUp() {
function getFollows(id = getCurrentUserId(), cursor = -1, count = 5000) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open("GET", `https://api.twitter.com/1.1/friends/ids.json?user_id=${id}&cursor=${cursor}&stringify_ids=true&count=${count}`, true);
xhr.open("GET", `https://api.${location.hostname}/1.1/friends/ids.json?user_id=${id}&cursor=${cursor}&stringify_ids=true&count=${count}`, true);
xhr.setRequestHeader("X-Twitter-Active-User", "yes");
xhr.setRequestHeader("X-Twitter-Auth-Type", "OAuth2Session");
xhr.setRequestHeader("X-Twitter-Client-Language", "en");
Expand Down Expand Up @@ -1613,7 +1613,7 @@ const proxyRoutes = [
path: "/1.1/tweetdeck/clients/blackbird/all",
method: "GET",
beforeRequest: (xhr) => {
xhr.modUrl = `https://api.twitter.com/1.1/help/settings.json?meow`;
xhr.modUrl = `https://api.${location.hostname}/1.1/help/settings.json?meow`;
},
afterRequest: (xhr) => {
const state = {
Expand Down Expand Up @@ -1666,7 +1666,7 @@ const proxyRoutes = [
},
},
beforeRequest: (xhr) => {
xhr.modUrl = `https://api.twitter.com/1.1/help/settings.json?meow_push`;
xhr.modUrl = `https://api.${location.hostname}/1.1/help/settings.json?meow_push`;
xhr.modMethod = "GET";
},
beforeSendBody: (xhr, body) => {
Expand Down Expand Up @@ -1698,7 +1698,7 @@ const proxyRoutes = [
},
},
beforeRequest: (xhr) => {
xhr.modUrl = `https://api.twitter.com/1.1/help/settings.json?meow_feeds_push`;
xhr.modUrl = `https://api.${location.hostname}/1.1/help/settings.json?meow_feeds_push`;
xhr.modMethod = "GET";
},
beforeSendBody: (xhr, body) => {
Expand Down Expand Up @@ -1728,7 +1728,7 @@ const proxyRoutes = [
},
},
beforeRequest: (xhr) => {
xhr.modUrl = `https://api.twitter.com/1.1/help/settings.json?meow_columns_push`;
xhr.modUrl = `https://api.${location.hostname}/1.1/help/settings.json?meow_columns_push`;
xhr.modMethod = "GET";
},
beforeSendBody: (xhr, body) => {
Expand Down Expand Up @@ -1805,7 +1805,7 @@ XMLHttpRequest = function () {
} else {
method = method.toUpperCase();
}
if(this.modUrl.includes("api.twitter.com") || this.modUrl.includes("twitter.com/i/api")) {
if(this.modUrl.includes("api.twitter.com") || this.modUrl.includes("api.x.com") || this.modUrl.includes("twitter.com/i/api") || this.modUrl.includes("x.com/i/api")) {
if(localStorage.device_id) this.setRequestHeader('X-Client-UUID', localStorage.device_id);
if(window.solveChallenge) {
try {
Expand Down

0 comments on commit 8ba2d21

Please sign in to comment.