Skip to content

Commit

Permalink
blacklisted pages
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed Aug 15, 2022
1 parent 4603b93 commit ae423f2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion layouts/header/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ setTimeout(async () => {
});
}
let about = document.getElementById('about');
if(about) {
if(about && !location.pathname.startsWith('/old/')) {
let a = document.createElement('a');
a.href = location.href.replace('twitter.com', 'mobile.twitter.com');
setInterval(() => {
Expand Down
5 changes: 4 additions & 1 deletion scripts/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let pages = [
},
];

let realPath = window.location.pathname.split('?')[0].split('#')[0];
let realPath = location.pathname.split('?')[0].split('#')[0];
if (realPath.endsWith("/")) {
realPath = realPath.slice(0, -1);
}
Expand All @@ -46,6 +46,9 @@ if(/^\/[A-z-0-9-_]{1,15}\/status\/\d{5,32}\/photo\/\d+(|\/)$/.test(realPath)) {
let path = realPath.split("/photo/")[0];
location.href = path;
}
if(/^\/[A-z-0-9-_]{1,15}\/status\/\d{5,32}\/analytics(|\/)$/.test(realPath)) {
location.href = location.href.replace('twitter.com', 'mobile.twitter.com');
}
let page = realPath === "" ? pages[0] : pages.find(p => (!p.exclude || !p.exclude.includes(realPath)) && (p.paths.includes(realPath) || p.paths.find(r => r instanceof RegExp && r.test(realPath))));

(async () => {
Expand Down
19 changes: 19 additions & 0 deletions scripts/newtwitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@ let r = document.createElement('a');
r.href = location.href.replace('mobile.twitter.com', 'twitter.com');
setInterval(() => {
r.href = location.href.replace('mobile.twitter.com', 'twitter.com');
let realPath = location.pathname.split('?')[0].split('#')[0];
if (realPath.endsWith("/")) {
realPath = realPath.slice(0, -1);
}
if(
/^\/[A-z-0-9-_]{1,15}\/status\/\d{5,32}\/analytics$/.test(realPath) ||
realPath.startsWith('/i/') ||
realPath === '/explore' ||
realPath === '/login' ||
realPath === '/register' ||
realPath === '/logout' ||
realPath === '/account/switch' ||
realPath.endsWith('/lists') ||
realPath.endsWith('/topics')
) {
r.hidden = true;
} else {
r.hidden = false;
}
}, 500);
r.textContent = 'Open this page in OldTwitter';
r.style.cssText = 'position: fixed; top: 0; right: 10px; padding: 0.5em; background: #fff; color: #000; font-family: Arial, sans-serif;border-radius:3px;';
Expand Down

0 comments on commit ae423f2

Please sign in to comment.