1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-22 18:15:47 +02:00

Fix broken forced redirect from plain twitter.com to TweetDeck

This commit is contained in:
chylex 2022-01-01 19:44:01 +01:00
parent a7a5723c4b
commit 5f60852fbb
Signed by: chylex
GPG Key ID: 4DE42C8F19A80548
21 changed files with 46 additions and 18 deletions

View File

@ -6,6 +6,7 @@
import introduction from "./introduction/introduction.js";
import hide_cookie_bar from "./login/hide_cookie_bar.js";
import redirect_plain_twitter_com from "./login/redirect_plain_twitter_com";
import setup_document_attributes from "./login/setup_document_attributes.js";
import add_skip_button from "./notification/add_skip_button.js";
import disable_clipboard_formatting_notification from "./notification/disable_clipboard_formatting.js";

View File

@ -1,4 +1,4 @@
import { crashDebug } from "../../api/utils.js";
import { crashDebug } from "./utils.js";
/**
* @callback FunctionReplacementCallback

View File

@ -0,0 +1,23 @@
import { replaceFunction } from "../api/patch.js";
function redirectToTweetDeck() {
location.href = "https://tweetdeck.twitter.com";
}
function hookHistoryStateFunction(func, args) {
debugger;
if (args[2] === "/") {
redirectToTweetDeck();
}
else {
func.apply(this, args);
}
}
/**
* Redirects plain twitter.com to TweetDeck, so that users cannot accidentally land on twitter.com login.
*/
export default function() {
replaceFunction(window.history, "pushState", hookHistoryStateFunction);
replaceFunction(window.history, "replaceState", hookHistoryStateFunction);
};

View File

@ -1,3 +1,6 @@
/**
* Sets up attributes on the <html> element for styling login/logout pages.
*/
export default function() {
if (location.pathname === "/login") {
document.documentElement.setAttribute("login", "");

View File

@ -1,7 +1,7 @@
import { $TD } from "../api/bridge.js";
import { replaceFunction } from "../api/patch.js";
import { TD } from "../api/td.js";
import { checkPropertyExists } from "../api/utils.js";
import { replaceFunction } from "./globals/patch_functions.js";
/**
* @property {string[]} eventNames

View File

@ -1,7 +1,7 @@
import { $TDX } from "../api/bridge.js";
import { replaceFunction } from "../api/patch.js";
import { TD } from "../api/td.js";
import { ensurePropertyExists } from "../api/utils.js";
import { replaceFunction } from "./globals/patch_functions.js";
/**
* Sets language for automatic translations.

View File

@ -1,7 +1,7 @@
import { $TDX } from "../api/bridge.js";
import { runAfterFunction } from "../api/patch.js";
import { TD } from "../api/td.js";
import { ensurePropertyExists } from "../api/utils.js";
import { runAfterFunction } from "./globals/patch_functions.js";
function focusDmInput() {
document.querySelector(".js-reply-tweetbox").focus();

View File

@ -1,7 +1,7 @@
import { $ } from "../api/jquery.js";
import { runAfterFunction } from "../api/patch.js";
import { TD } from "../api/td.js";
import { ensurePropertyExists } from "../api/utils.js";
import { runAfterFunction } from "./globals/patch_functions.js";
import { prioritizeNewestEvent } from "./globals/prioritize_newest_event.js";
/**

View File

@ -1,6 +1,6 @@
import { replaceFunction } from "../api/patch.js";
import { TD } from "../api/td.js";
import { ensurePropertyExists } from "../api/utils.js";
import { replaceFunction } from "./globals/patch_functions.js";
const formatRegex = /\?.*format=(\w+)/;

View File

@ -1,6 +1,6 @@
import { replaceFunction } from "../api/patch.js";
import { TD } from "../api/td.js";
import { ensurePropertyExists } from "../api/utils.js";
import { replaceFunction } from "./globals/patch_functions.js";
/**
* Adds missing languages for Bing Translator (Bengali, Icelandic, Tagalog, Tamil, Telugu, Urdu).

View File

@ -1,6 +1,6 @@
import { $ } from "../api/jquery.js";
import { replaceFunction } from "../api/patch.js";
import { onAppReady } from "../api/ready.js";
import { replaceFunction } from "./globals/patch_functions.js";
import { prioritizeNewestEvent } from "./globals/prioritize_newest_event.js";
/**

View File

@ -1,9 +1,9 @@
import { $TD } from "../api/bridge.js";
import { runAfterFunction } from "../api/patch.js";
import { onAppReady } from "../api/ready.js";
import { TD } from "../api/td.js";
import { ensurePropertyExists } from "../api/utils.js";
import { getClassStyleProperty } from "./globals/get_class_style_property.js";
import { runAfterFunction } from "./globals/patch_functions.js";
function refreshSettings() {
const fontSizeName = TD.settings.getFontSize();

View File

@ -1,8 +1,8 @@
// noinspection JSUnusedGlobalSymbols
import { replaceFunction } from "../api/patch.js";
import { TD } from "../api/td.js";
import { ensurePropertyExists } from "../api/utils.js";
import { replaceFunction } from "./globals/patch_functions.js";
/**
* Limits amount of loaded DMs to avoid massive lag from re-opening them several times.

View File

@ -1,7 +1,7 @@
import { runAfterFunction } from "../api/patch.js";
import { TD } from "../api/td.js";
import { checkPropertyExists } from "../api/utils.js";
import { injectMustache } from "./globals/inject_mustache.js";
import { runAfterFunction } from "./globals/patch_functions.js";
/**
* Makes texts saying 'Retweet' lowercase.

View File

@ -1,7 +1,7 @@
import { $ } from "../api/jquery.js";
import { replaceFunction } from "../api/patch.js";
import { TD } from "../api/td.js";
import { checkPropertyExists } from "../api/utils.js";
import { replaceFunction } from "./globals/patch_functions.js";
/**
* Allows restoring cleared columns by holding Shift.

View File

@ -1,9 +1,9 @@
import { $TD, $TDX } from "../api/bridge.js";
import { $ } from "../api/jquery.js";
import { replaceFunction } from "../api/patch.js";
import { TD } from "../api/td.js";
import { checkPropertyExists, ensurePropertyExists } from "../api/utils.js";
import { getColumnName } from "./globals/get_column_name.js";
import { replaceFunction } from "./globals/patch_functions.js";
/**
* Event callback for a new tweet.

View File

@ -1,6 +1,6 @@
import { $TDX } from "../api/bridge.js";
import { replaceFunction } from "../api/patch.js";
import { isAppReady } from "../api/ready.js";
import { replaceFunction } from "./globals/patch_functions.js";
/**
* Adds support for sound notification settings.

View File

@ -1,6 +1,6 @@
import { replaceFunction } from "../api/patch.js";
import { TD } from "../api/td.js";
import { checkPropertyExists } from "../api/utils.js";
import { replaceFunction } from "./globals/patch_functions.js";
/**
* Replaces displayed name and avatar of the official TweetDuck account.

View File

@ -1,9 +1,9 @@
import { $TD } from "../api/bridge.js";
import { replaceFunction, runAfterFunction } from "../api/patch.js";
import { TD } from "../api/td.js";
import { checkPropertyExists, noop } from "../api/utils.js";
import { getHoveredTweet } from "./globals/get_hovered_tweet.js";
import { injectMustache } from "./globals/inject_mustache.js";
import { replaceFunction, runAfterFunction } from "./globals/patch_functions.js";
/**
* @param {HTMLElement} ele

View File

@ -1,6 +1,6 @@
import { replaceFunction } from "../api/patch.js";
import { TD } from "../api/td.js";
import { ensurePropertyExists } from "../api/utils.js";
import { replaceFunction } from "./globals/patch_functions.js";
/**
* Skips the pre-login page so that users immediately see the login page.

View File

@ -389,6 +389,7 @@
<Content Include="Resources\Content\.all.js" />
<Content Include="Resources\Content\api\bridge.js" />
<Content Include="Resources\Content\api\jquery.js" />
<Content Include="Resources\Content\api\patch.js" />
<Content Include="Resources\Content\api\ready.js" />
<Content Include="Resources\Content\api\td.js" />
<Content Include="Resources\Content\api\utils.js" />
@ -398,6 +399,7 @@
<Content Include="Resources\Content\load.js" />
<Content Include="Resources\Content\login\hide_cookie_bar.js" />
<Content Include="Resources\Content\login\login.css" />
<Content Include="Resources\Content\login\redirect_plain_twitter_com.js" />
<Content Include="Resources\Content\login\setup_document_attributes.js" />
<Content Include="Resources\Content\notification\add_skip_button.js" />
<Content Include="Resources\Content\notification\disable_clipboard_formatting.js" />
@ -436,7 +438,6 @@
<Content Include="Resources\Content\tweetdeck\globals\get_hovered_column.js" />
<Content Include="Resources\Content\tweetdeck\globals\get_hovered_tweet.js" />
<Content Include="Resources\Content\tweetdeck\globals\inject_mustache.js" />
<Content Include="Resources\Content\tweetdeck\globals\patch_functions.js" />
<Content Include="Resources\Content\tweetdeck\globals\prioritize_newest_event.js" />
<Content Include="Resources\Content\tweetdeck\globals\reload_browser.js" />
<Content Include="Resources\Content\tweetdeck\globals\reload_columns.js" />