From 99a89bbe80b20a9d3345e9dadacd2f588c98750a Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Fri, 19 Oct 2018 11:40:39 +0200 Subject: [PATCH] Fixed OTB --- Plugins/ChatFilter/ChatFilter.plugin.js | 10 ++--- Plugins/OldTitleBar/OldTitleBar.plugin.js | 9 ++--- Plugins/PluginRepo/PluginRepo.plugin.js | 40 ++++--------------- Plugins/RepoControls/RepoControls.plugin.js | 26 ++++--------- Plugins/ThemeRepo/ThemeRepo.plugin.js | 43 ++++----------------- 5 files changed, 29 insertions(+), 99 deletions(-) diff --git a/Plugins/ChatFilter/ChatFilter.plugin.js b/Plugins/ChatFilter/ChatFilter.plugin.js index f0e6550fe9..86b137502d 100644 --- a/Plugins/ChatFilter/ChatFilter.plugin.js +++ b/Plugins/ChatFilter/ChatFilter.plugin.js @@ -32,7 +32,7 @@ class ChatFilter { getDescription () {return "Allows the user to censor words or block complete messages based on words in the chatwindow.";} - getVersion () {return "3.2.3";} + getVersion () {return "3.2.4";} getAuthor () {return "DevilBro";} @@ -330,8 +330,8 @@ class ChatFilter { if (reg.test(url)) blocked = true; } else if (string.indexOf("<") != 0) { - string.split(" ").forEach((word) => { - if (reg.test(word)) blocked = true; + string.split(/[\s\n\r]/).forEach((word) => { + if (word && reg.test(word)) blocked = true; }); } }); @@ -372,8 +372,8 @@ class ChatFilter { } else if (string.indexOf("<") != 0) { var newstring = []; - string.split(" ").forEach((word) => { - newstring.push(reg.test(word) ? BDFDB.encodeToHTML(censoredReplace) : word); + string.split(/[\s\n\r]/).forEach((word) => { + newstring.push(word && reg.test(word) ? BDFDB.encodeToHTML(censoredReplace) : word); }); strings[i] = newstring.join(" "); } diff --git a/Plugins/OldTitleBar/OldTitleBar.plugin.js b/Plugins/OldTitleBar/OldTitleBar.plugin.js index 935bccbb90..e00f3c6603 100644 --- a/Plugins/OldTitleBar/OldTitleBar.plugin.js +++ b/Plugins/OldTitleBar/OldTitleBar.plugin.js @@ -90,7 +90,7 @@ class OldTitleBar { getDescription () {return "Reverts the title bar back to its former self.";} - getVersion () {return "1.4.5";} + getVersion () {return "1.4.6";} getAuthor () {return "DevilBro";} @@ -347,11 +347,8 @@ class OldTitleBar { } patchMainScreen (enable) { - let fs = require("fs") - let mainScreenPath = require("path").resolve(BDFDB.getDiscordFolder(), "modules/discord_desktop_core/core/app/mainScreen.js"); - let mainScreen = fs.readFileSync(mainScreenPath).toString(); - if (!mainScreen.includes("frame: " + enable) || !mainScreen.includes(".frame = " + enable)) { - fs.writeFileSync(mainScreenPath, mainScreen.replace("frame: " + !enable, "frame: " + enable).replace(".frame = " + !enable, ".frame = " + enable)); + if (BdApi.getWindowPreference("frame") != enable) { + BdApi.setWindowPreference("frame", enable); return true; } return false; diff --git a/Plugins/PluginRepo/PluginRepo.plugin.js b/Plugins/PluginRepo/PluginRepo.plugin.js index e5544dcb1e..68a5f9f7cc 100644 --- a/Plugins/PluginRepo/PluginRepo.plugin.js +++ b/Plugins/PluginRepo/PluginRepo.plugin.js @@ -35,27 +35,7 @@ class PluginRepo { `; this.pluginEntryMarkup = - `
  • -
    - -
    -
    -
    -
    -
    -
    - - -
    - -
    -
  • `; - - this.pluginEntryZackMarkup = - `
  • + `
  • v by @@ -123,7 +103,7 @@ class PluginRepo {
    -

    To expierence PluginRepo in the best way. I would recommend you to download Restart-No-More, which automatically loads newly downloaded Plugins into your BetterDiscord, so you won't have to reload after downloading a Plugin.

    +

    To expierence PluginRepo in the best way. I would recommend you to enable BD intern reload function, that way all downloaded files are loaded into Discord without the need to reload.

    Hide updated Plugins.

    @@ -181,7 +161,7 @@ class PluginRepo { .pluginrepo-modal ${BDFDB.dotCN.modalinner} { min-height: 100%; } - .pluginrepo-modal .pluginEntry.zack { + .pluginrepo-modal .pluginEntry { overflow: visible !important; } .pluginrepo-modal .pluginEntry .gitIcon, @@ -544,7 +524,7 @@ class PluginRepo { modal.entries = []; for (let url in this.loadedPlugins) { let plugin = this.loadedPlugins[url]; - let div = BDFDB.zacksFork() ? $(this.pluginEntryZackMarkup) : $(this.pluginEntryMarkup); + let div = $(this.pluginEntryMarkup); var installedPlugin = window.bdplugins[plugin.getName] ? window.bdplugins[plugin.getName].plugin : null; if (installedPlugin && installedPlugin.getAuthor().toUpperCase() == plugin.getAuthor.toUpperCase()) { if (installedPlugin.getVersion() != plugin.getVersion) { @@ -611,16 +591,10 @@ class PluginRepo { if (searchstring.length > 0) { for (let i in values) values[i] = BDFDB.highlightText(values[i], searchstring); } - if (BDFDB.zacksFork()) { - div.find(".bda-name").html(values[0]); - div.find(".bda-version").html(values[1]); - div.find(".bda-author").html(values[2]); - } - else { - div.find(".bda-name").html(values[0] + " v" + values[1] + " by " + values[2]); - } + div.find(".bda-name").html(values[0]); + div.find(".bda-version").html(values[1]); + div.find(".bda-author").html(values[2]); div.find(".bda-description").html(values[3]); - div .on("click." + this.getName(), ".favIcon", (e) => { e.currentTarget.classList.toggle("favorized"); diff --git a/Plugins/RepoControls/RepoControls.plugin.js b/Plugins/RepoControls/RepoControls.plugin.js index 8398bc1112..db42595a4b 100644 --- a/Plugins/RepoControls/RepoControls.plugin.js +++ b/Plugins/RepoControls/RepoControls.plugin.js @@ -154,8 +154,7 @@ class RepoControls { start () { var libraryScript = null; - if (typeof BDFDB !== "object" || BDFDB.isLibraryOutdated()) { - if (typeof BDFDB === "object") BDFDB = ""; + if (typeof BDFDB !== "object" || typeof BDFDB.isLibraryOutdated !== "function" || BDFDB.isLibraryOutdated()) { libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]'); if (libraryScript) libraryScript.remove(); libraryScript = document.createElement("script"); @@ -164,7 +163,7 @@ class RepoControls { document.head.appendChild(libraryScript); } this.startTimeout = setTimeout(() => {this.initialize();}, 30000); - if (typeof BDFDB === "object") this.initialize(); + if (typeof BDFDB === "object" && typeof BDFDB.isLibraryOutdated === "function") this.initialize(); else libraryScript.addEventListener("load", () => {this.initialize();}); } @@ -340,22 +339,11 @@ class RepoControls { getEntry (repoControls, li) { if (!repoControls || !li || !li.tagName || !li.querySelector(".bda-name")) return null; - let name, version, author, description, enabled; - if (BDFDB.zacksFork()) { - name = li.querySelector(".bda-name").textContent; - version = li.querySelector(".bda-version").textContent; - author = li.querySelector(".bda-author").textContent; - description = li.querySelector(".bda-description").textContent; - enabled = li.querySelector(".ui-switch-checkbox").checked; - } - else { - let namestring = li.querySelector(".bda-name").textContent; - name = namestring.split(" v")[0]; - version = namestring.split(" v")[1].split(" by ")[0]; - author = namestring.split(" by ")[1]; - description = li.querySelector(".bda-description").textContent; - enabled = li.querySelector(".ui-switch-checkbox").checked; - } + let name = li.querySelector(".bda-name").textContent; + let version = li.querySelector(".bda-version").textContent; + let author = li.querySelector(".bda-author").textContent; + let description = li.querySelector(".bda-description").textContent; + let enabled = li.querySelector(".ui-switch-checkbox").checked; let type = this.getSettingsPageType(); let pathstatscache = type ? repoControls[type][name] : null; return { diff --git a/Plugins/ThemeRepo/ThemeRepo.plugin.js b/Plugins/ThemeRepo/ThemeRepo.plugin.js index 3a433be340..ad444c23c4 100644 --- a/Plugins/ThemeRepo/ThemeRepo.plugin.js +++ b/Plugins/ThemeRepo/ThemeRepo.plugin.js @@ -40,30 +40,7 @@ class ThemeRepo { ``; this.themeEntryMarkup = - `
  • -
    - -
    -
    -
    -
    -
    -
    - - -
    - -
    -
    - -
    -
  • `; - - this.themeEntryZackMarkup = - `
  • + `
  • v by @@ -179,7 +156,7 @@ class ThemeRepo {
    -

    Apply Theme after Download (Restart-No-More needed)

    +

    Apply Theme after Download (Automatic loading enabled)

    @@ -236,7 +213,7 @@ class ThemeRepo { .themerepo-modal ${BDFDB.dotCN.modalinner} { min-height: 100%; } - .themerepo-modal .themeEntry.zack { + .themerepo-modal .themeEntry { overflow: visible !important; } .themerepo-modal .themeEntry .gitIcon, @@ -657,7 +634,7 @@ class ThemeRepo { modal.entries = []; for (let url in this.loadedThemes) { let theme = this.loadedThemes[url]; - let div = BDFDB.zacksFork() ? $(this.themeEntryZackMarkup) : $(this.themeEntryMarkup); + let div = $(this.themeEntryMarkup); var installedTheme = window.bdthemes[this.loadedThemes[url].name]; if (installedTheme && installedTheme.author.toUpperCase() == theme.author.toUpperCase()) { @@ -726,16 +703,10 @@ class ThemeRepo { if (searchstring.length > 0) { for (let i in values) values[i] = BDFDB.highlightText(values[i], searchstring); } - if (BDFDB.zacksFork()) { - div.find(".bda-name").html(values[0]); - div.find(".bda-version").html(values[1]); - div.find(".bda-author").html(values[2]); - } - else { - div.find(".bda-name").html(values[0] + " v" + values[1] + " by " + values[2]); - } + div.find(".bda-name").html(values[0]); + div.find(".bda-version").html(values[1]); + div.find(".bda-author").html(values[2]); div.find(".bda-description").html(values[3]); - div .on("change." + this.getName(), ".previewCheckbox", (e) => { modal.find(".previewCheckbox").not(e.target).prop("checked", false);