diff --git a/layouts/header/script.js b/layouts/header/script.js index 4e229589..863af618 100644 --- a/layouts/header/script.js +++ b/layouts/header/script.js @@ -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(() => { diff --git a/scripts/content.js b/scripts/content.js index b1199f74..4178003a 100644 --- a/scripts/content.js +++ b/scripts/content.js @@ -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); } @@ -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 () => { diff --git a/scripts/newtwitter.js b/scripts/newtwitter.js index 03c3e222..0930da02 100644 --- a/scripts/newtwitter.js +++ b/scripts/newtwitter.js @@ -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;';