fix ps
This commit is contained in:
parent
d21f492bf3
commit
41bde44755
134
js/main.js
134
js/main.js
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,26 @@
|
||||||
|
import {settingsCookie} from "./0globals";
|
||||||
|
import BDV2 from "./v2";
|
||||||
|
import Utils from "./utils";
|
||||||
|
|
||||||
|
export default new class TFHour {
|
||||||
|
inject24Hour() {
|
||||||
|
if (this.cancel24Hour) return;
|
||||||
|
|
||||||
|
const twelveHour = new RegExp(`([0-9]{1,2}):([0-9]{1,2})\\s(AM|PM)`);
|
||||||
|
const convert = (data) => {
|
||||||
|
if (!settingsCookie["bda-gs-6"]) return;
|
||||||
|
const matched = data.returnValue.match(twelveHour);
|
||||||
|
if (!matched || matched.length !== 4) return;
|
||||||
|
if (matched[3] === "AM") return data.returnValue = data.returnValue.replace(matched[0], `${matched[1] === "12" ? "00" : matched[1].padStart(2, "0")}:${matched[2]}`);
|
||||||
|
return data.returnValue = data.returnValue.replace(matched[0], `${matched[1] === "12" ? "12" : parseInt(matched[1]) + 12}:${matched[2]}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
const cancelCozy = Utils.monkeyPatch(BDV2.TimeFormatter, "calendarFormat", {after: convert}); // Called in Cozy mode
|
||||||
|
const cancelCompact = Utils.monkeyPatch(BDV2.TimeFormatter, "dateFormat", {after: convert}); // Called in Compact mode
|
||||||
|
this.cancel24Hour = () => {cancelCozy(); cancelCompact();}; // Cancel both
|
||||||
|
}
|
||||||
|
|
||||||
|
remove24Hour() {
|
||||||
|
if (this.cancel24Hour) this.cancel24Hour();
|
||||||
|
}
|
||||||
|
};
|
17
src/core.js
17
src/core.js
|
@ -182,23 +182,6 @@ Core.prototype.initObserver = function () {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Core.prototype.inject24Hour = function() {
|
|
||||||
if (this.cancel24Hour) return;
|
|
||||||
|
|
||||||
const twelveHour = new RegExp(`([0-9]{1,2}):([0-9]{1,2})\\s(AM|PM)`);
|
|
||||||
const convert = (data) => {
|
|
||||||
if (!settingsCookie["bda-gs-6"]) return;
|
|
||||||
const matched = data.returnValue.match(twelveHour);
|
|
||||||
if (!matched || matched.length !== 4) return;
|
|
||||||
if (matched[3] === "AM") return data.returnValue = data.returnValue.replace(matched[0], `${matched[1] === "12" ? "00" : matched[1].padStart(2, "0")}:${matched[2]}`);
|
|
||||||
return data.returnValue = data.returnValue.replace(matched[0], `${matched[1] === "12" ? "12" : parseInt(matched[1]) + 12}:${matched[2]}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
const cancelCozy = Utils.monkeyPatch(BDV2.TimeFormatter, "calendarFormat", {after: convert}); // Called in Cozy mode
|
|
||||||
const cancelCompact = Utils.monkeyPatch(BDV2.TimeFormatter, "dateFormat", {after: convert}); // Called in Compact mode
|
|
||||||
this.cancel24Hour = () => {cancelCozy(); cancelCompact();}; // Cancel both
|
|
||||||
};
|
|
||||||
|
|
||||||
Core.prototype.showChangelogModal = function(options = {}) {
|
Core.prototype.showChangelogModal = function(options = {}) {
|
||||||
const ModalStack = WebpackModules.findByProps("push", "update", "pop", "popWithKey");
|
const ModalStack = WebpackModules.findByProps("push", "update", "pop", "popWithKey");
|
||||||
const ChangelogClasses = WebpackModules.findByProps("fixed", "improved");
|
const ChangelogClasses = WebpackModules.findByProps("fixed", "improved");
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import {settingsCookie} from "./0globals";
|
import {settingsCookie} from "./0globals";
|
||||||
import BDV2 from "./v2";
|
import BDV2 from "./v2";
|
||||||
import webpackModules from "./webpackModules";
|
import webpackModules from "./webpackModules";
|
||||||
|
import Utils from "./utils";
|
||||||
|
|
||||||
import V2C_PublicServers from "./react/publicServers";
|
import V2C_PublicServers from "./react/publicServers";
|
||||||
import Layer from "./react/layer";
|
import Layer from "./react/layer";
|
||||||
|
@ -66,8 +67,8 @@ export default new class V2_PublicServers {
|
||||||
|
|
||||||
addButton() {
|
addButton() {
|
||||||
if (this.guildPatch) return;
|
if (this.guildPatch) return;
|
||||||
const GuildList = webpackModules.findModuleByDisplayName("Guilds");
|
const GuildList = webpackModules.findByDisplayName("Guilds");
|
||||||
this.guildPatch = webpackModules.monkeyPatch(GuildList.prototype, "render", {after: this._appendButton});
|
this.guildPatch = Utils.monkeyPatch(GuildList.prototype, "render", {after: this._appendButton});
|
||||||
this._appendButton();
|
this._appendButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import BDEvents from "./bdEvents";
|
||||||
import pluginModule from "./pluginModule";
|
import pluginModule from "./pluginModule";
|
||||||
import themeModule from "./themeModule";
|
import themeModule from "./themeModule";
|
||||||
import coloredText from "./coloredText";
|
import coloredText from "./coloredText";
|
||||||
|
import tfHour from "./24hour";
|
||||||
|
|
||||||
import publicServersModule from "./publicServers";
|
import publicServersModule from "./publicServers";
|
||||||
import voiceMode from "./voiceMode";
|
import voiceMode from "./voiceMode";
|
||||||
|
@ -144,7 +145,7 @@ export default new class V2_SettingsPanel {
|
||||||
else $("#app-mount").removeClass("bda-dark");
|
else $("#app-mount").removeClass("bda-dark");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enabled && id == "bda-gs-6") coloredText.inject24Hour();
|
if (enabled && id == "bda-gs-6") tfHour.inject24Hour();
|
||||||
|
|
||||||
if (id == "bda-gs-7") {
|
if (id == "bda-gs-7") {
|
||||||
if (enabled) coloredText.injectColoredText();
|
if (enabled) coloredText.injectColoredText();
|
||||||
|
@ -196,7 +197,7 @@ export default new class V2_SettingsPanel {
|
||||||
this.saveSettings();
|
this.saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeSettings() {
|
async initializeSettings() {
|
||||||
|
|
||||||
// if (settingsCookie["bda-gs-b"]) $("body").addClass("bd-blue");
|
// if (settingsCookie["bda-gs-b"]) $("body").addClass("bd-blue");
|
||||||
if (settingsCookie["bda-gs-2"]) $("body").addClass("bd-minimal");
|
if (settingsCookie["bda-gs-2"]) $("body").addClass("bd-minimal");
|
||||||
|
@ -204,7 +205,7 @@ export default new class V2_SettingsPanel {
|
||||||
if (settingsCookie["bda-gs-1"]) publicServersModule.addButton();
|
if (settingsCookie["bda-gs-1"]) publicServersModule.addButton();
|
||||||
if (settingsCookie["bda-gs-4"]) voiceMode.enable();
|
if (settingsCookie["bda-gs-4"]) voiceMode.enable();
|
||||||
if (settingsCookie["bda-gs-5"]) $("#app-mount").addClass("bda-dark");
|
if (settingsCookie["bda-gs-5"]) $("#app-mount").addClass("bda-dark");
|
||||||
if (settingsCookie["bda-gs-6"]) coloredText.inject24Hour();
|
if (settingsCookie["bda-gs-6"]) tfHour.inject24Hour();
|
||||||
if (settingsCookie["bda-gs-7"]) coloredText.injectColoredText();
|
if (settingsCookie["bda-gs-7"]) coloredText.injectColoredText();
|
||||||
if (settingsCookie["bda-es-4"]) emoteModule.autoCapitalize();
|
if (settingsCookie["bda-es-4"]) emoteModule.autoCapitalize();
|
||||||
if (settingsCookie["fork-ps-4"]) ClassNormalizer.start();
|
if (settingsCookie["fork-ps-4"]) ClassNormalizer.start();
|
||||||
|
@ -222,7 +223,7 @@ export default new class V2_SettingsPanel {
|
||||||
saveSettings() {
|
saveSettings() {
|
||||||
DataStore.setSettingGroup("settings", settingsCookie);
|
DataStore.setSettingGroup("settings", settingsCookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSettings() {
|
loadSettings() {
|
||||||
Object.assign(settingsCookie, DataStore.getSettingGroup("settings"));
|
Object.assign(settingsCookie, DataStore.getSettingGroup("settings"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ const CircularDependencyPlugin = require("circular-dependency-plugin");
|
||||||
module.exports = {
|
module.exports = {
|
||||||
mode: "development",
|
mode: "development",
|
||||||
target: "node",
|
target: "node",
|
||||||
devtool: "eval-source-map",
|
devtool: "eval-cheap-source-map",
|
||||||
entry: "./src/index.js",
|
entry: "./src/index.js",
|
||||||
output: {
|
output: {
|
||||||
filename: "main.js",
|
filename: "main.js",
|
||||||
|
|
Loading…
Reference in New Issue