Skip to content

Commit

Permalink
support dm urls
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed Sep 5, 2022
1 parent 108448f commit 862804f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions layouts/profile/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2332,6 +2332,13 @@ setTimeout(async () => {
} else if(subpage === 'lists') {
renderLists();
}
if(location.hash === "#dm") {
setTimeout(() => {
let event = new CustomEvent('messageUser', { detail: { id: `${user.id_str}-${pageUser.id_str}`, user: pageUser } });
document.dispatchEvent(event);
location.hash = "";
}, 1000);
}
renderDiscovery();
renderTrends();
setInterval(() => renderDiscovery(false), 60000 * 5);
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Old Twitter Layout (2022)",
"description": "A new extension that returns old Twitter's look.",
"version": "1.5.4.2",
"version": "1.5.5",
"manifest_version": 3,
"homepage_url": "https://github.com/dimdenGD/OldTwitter",
"background": {
Expand Down
4 changes: 4 additions & 0 deletions scripts/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ let realPath = location.pathname.split('?')[0].split('#')[0];
if (realPath.endsWith("/")) {
realPath = realPath.slice(0, -1);
}

if (realPath.startsWith("/i/user/")) {
let id = realPath.split("/i/user/")[1];
if (id.endsWith("/")) id = id.slice(0, -1);
Expand All @@ -50,6 +51,9 @@ if (realPath.startsWith("/i/user/")) {
location.href = "/" + user.screen_name;
});
}
if(/^\/direct_messages\/create\/[A-z-0-9-_]{1,15}$/.test(realPath)) {
location.href = `https://twitter.com/${realPath.split("/direct_messages/create/")[1]}#dm`;
}
if(/^\/[A-z-0-9-_]{1,15}\/status\/\d{5,32}\/photo\/\d+(|\/)$/.test(realPath)) {
let path = realPath.split("/photo/")[0];
location.href = path;
Expand Down

0 comments on commit 862804f

Please sign in to comment.