Skip to content

Commit

Permalink
Merge pull request #508 from cirx1e/master
Browse files Browse the repository at this point in the history
feat(injection): add 'newtwitter' parameter for unsupported pages
  • Loading branch information
dimdenGD authored Sep 8, 2023
2 parents 6f57dd3 + a99d110 commit 1c69021
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions scripts/injection.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ let pages = [
];

let realPath = location.pathname;
let hrefUrl = location.href;
if (realPath.endsWith("/") && realPath !== "/") {
location.replace(realPath.slice(0, -1));
}
Expand Down Expand Up @@ -116,13 +117,19 @@ if(realPath === '/intent/follow') {
let screen_name = location.search.split('screen_name=')[1].split('&')[0];
location.replace(`/${screen_name}`);
}
if(
/^\/[A-z-0-9-_]{1,15}\/status\/\d{5,32}\/analytics$/.test(realPath) ||
/^\/i\/events\/\d{5,32}$/.test(realPath) ||
realPath.startsWith('/settings/') ||
realPath.startsWith('/i/flow/')
if (!hrefUrl.includes('newtwitter=true') &&
(
realPath.startsWith('/i/flow/') ||
realPath.startsWith('/i/premium_sign_up/') ||
realPath.startsWith('/i/events/') ||
realPath.startsWith('/i/spaces/') ||
realPath.startsWith('/settings') ||
/^\/[A-z-0-9-_]{1,15}\/status\/\d{5,32}\/analytics$/.test(realPath)
)
) {
location.replace(location.href.replace('twitter.com', 'mobile.twitter.com'));
let url = new URL(hrefUrl)
url.searchParams.set('newtwitter', 'true');
location.replace(url);
}
const LANGUAGES = ["en", "ru", "uk", "fr", "pt_BR", "es", "el", "ro", "tl", "lv", "he", "ne", "nl", "ja", "tr", "it", "ar", "th", "ko", "pl", "vi", "zh_CN", "zh_TW", "cs", "de", "ca"];
const TRANSLATORS = {
Expand Down

0 comments on commit 1c69021

Please sign in to comment.