This commit is contained in:
Mirco Wittrien 2019-11-05 21:16:39 +01:00
parent df7c3638cd
commit 66828148db
5 changed files with 178 additions and 175 deletions

View File

@ -15,9 +15,9 @@ class BadgesEverywhere {
};
this.patchModules = {
"MemberListItem":"render",
"MessageUsername":"render",
"UserPopout":"render"
MemberListItem: "render",
MessageUsername: "render",
UserPopout: "render"
};
}
@ -129,23 +129,26 @@ class BadgesEverywhere {
let indicators = BDFDB.DataUtils.get(this, "indicators");
let settingsitems = [], inneritems = [];
for (let key in settings) settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSwitch, {
for (let key in settings) settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
for (let flag in badges) inneritems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSwitch, {
for (let flag in badges) inneritems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["badges", flag],
label: this.defaults.badges[flag].name,
value: badges[flag],
labelchildren: this.createSettingsBadges(flag)
}));
for (let flag in indicators) inneritems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSwitch, {
for (let flag in indicators) inneritems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["indicators", flag],
label: this.defaults.indicators[flag].name,
@ -217,55 +220,56 @@ class BadgesEverywhere {
}
processMemberListItem (e) {
if (!BDFDB.DataUtils.get(this, "settings", "showInMemberList")) return;
if (e.instance.props.user) this.injectBadges(e.instance, BDFDB.ReactUtils.getValue(e.returnvalue, "props.decorators.props.children"), e.instance.props.user, "list");
if (e.instance.props.user && BDFDB.DataUtils.get(this, "settings", "showInMemberList")) {
this.injectBadges(e.instance, BDFDB.ReactUtils.getValue(e.returnvalue, "props.decorators.props.children"), e.instance.props.user, "list");
}
}
processMessageUsername (e) {
if (!BDFDB.DataUtils.get(this, "settings", "showInChat")) return;
let user = BDFDB.ReactUtils.getValue(e.instance, "props.message.author");
if (user) this.injectBadges(e.instance, BDFDB.ReactUtils.getValue(e.returnvalue, "props.children.props.children"), user, "chat");
if (user && BDFDB.DataUtils.get(this, "settings", "showInChat")) {
this.injectBadges(e.instance, BDFDB.ReactUtils.getValue(e.returnvalue, "props.children.props.children"), user, "chat");
}
}
processUserPopout (e) {
if (!BDFDB.DataUtils.get(this, "settings", "showInPopout")) return;
if (e.instance.props.user) {
if (e.instance.props.user && BDFDB.DataUtils.get(this, "settings", "showInPopout")) {
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name: "CustomStatus"});
if (index > -1) this.injectBadges(e.instance, children, e.instance.props.user, "popout", e.instance.props.activity && e.instance.props.activity.type != BDFDB.DiscordConstants.ActivityTypes.CUSTOM_STATUS);
}
}
injectBadges (instance, children, info, type, colored) {
if (!BDFDB.ArrayUtils.is(children) || !info || info.bot) return;
if (!BDFDB.ArrayUtils.is(this.requestedusers[info.id])) {
this.requestedusers[info.id] = [instance];
BDFDB.LibraryModules.APIUtils.get(BDFDB.DiscordConstants.Endpoints.USER_PROFILE(info.id)).then(result => {
injectBadges (instance, children, user, type, colored) {
if (!BDFDB.ArrayUtils.is(children) || !user || user.bot) return;
if (!BDFDB.ArrayUtils.is(this.requestedusers[user.id])) {
this.requestedusers[user.id] = [instance];
BDFDB.LibraryModules.APIUtils.get(BDFDB.DiscordConstants.Endpoints.USER_PROFILE(user.id)).then(result => {
let usercopy = Object.assign({}, result.body.user);
if (result.body.premium_since) usercopy.flags += this.nitroflag;
usercopy.premium_since = result.body.premium_since;
if (result.body.premium_guild_since) usercopy.flags += this.boostflag;
usercopy.premium_guild_since = result.body.premium_guild_since;
this.loadedusers[info.id] = usercopy;
for (let queredinstance of this.requestedusers[info.id]) BDFDB.ReactUtils.forceUpdate(queredinstance);
this.loadedusers[user.id] = usercopy;
for (let queredinstance of this.requestedusers[user.id]) BDFDB.ReactUtils.forceUpdate(queredinstance);
});
}
else if (!this.loadedusers[info.id]) this.requestedusers[info.id].push(instance);
else children.push(this.createBadges(info, type, colored));
else if (!this.loadedusers[user.id]) this.requestedusers[user.id].push(instance);
else children.push(this.createBadges(user, type, colored));
}
createBadges (info, type, uncolored) {
createBadges (user, type, uncolored) {
let badges = BDFDB.DataUtils.get(this, "badges");
let indicators = BDFDB.DataUtils.get(this, "indicators");
let settings = BDFDB.DataUtils.get(this, "settings");
if (uncolored == undefined) uncolored = !settings.useColoredVersion;
let badgewrapper = BDFDB.ReactUtils.elementToReact(BDFDB.DOMUtils.create(`<span class="BE-badges BE-badges-${type} ${uncolored ? BDFDB.disCN.userprofiletopsectionplaying : BDFDB.disCN.userprofiletopsectionnormal}" style="all: unset !important;"></span>`));
badgewrapper.props.children = [];
for (let flag in badges) if ((this.loadedusers[info.id].flags | flag) == this.loadedusers[info.id].flags && badges[flag]) {
badgewrapper.props.children.push(this.createBadge(settings.showNitroDate ? this.getTimeString(info.id, flag) : null, type, flag, flag == this.boostflag ? BDFDB.LibraryModules.GuildBoostUtils.getUserLevel(this.loadedusers[info.id].premium_guild_since) : null));
for (let flag in badges) if ((this.loadedusers[user.id].flags | flag) == this.loadedusers[user.id].flags && badges[flag]) {
badgewrapper.props.children.push(this.createBadge(settings.showNitroDate ? this.getTimeString(user.id, flag) : null, type, flag, flag == this.boostflag ? BDFDB.LibraryModules.GuildBoostUtils.getUserLevel(this.loadedusers[user.id].premium_guild_since) : null));
}
let member = BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), info.id);
let member = BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), user.id);
if (indicators.CURRENT_GUILD_BOOST && member && member.premiumSince) {
badgewrapper.props.children.push(this.createBadge(settings.showNitroDate ? this.getTimeString(info.id, "CURRENT_GUILD_BOOST") : null, type, "CURRENT_GUILD_BOOST"));
badgewrapper.props.children.push(this.createBadge(settings.showNitroDate ? this.getTimeString(user.id, "CURRENT_GUILD_BOOST") : null, type, "CURRENT_GUILD_BOOST"));
}
return badgewrapper.props.children.length ? badgewrapper : null;
}

View File

@ -622,7 +622,7 @@ class EditServers {
updateGuildSidebar() {
if (document.querySelector(BDFDB.dotCN.guildheader)) {
var ins = BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.app), {name: ["GuildSidebar", "GuildHeader"], all: true, noCopies: true, depth: 99999999, time: 99999999});
if (ins) for (let i in ins) ins[i].updater.enqueueForceUpdate(ins[i]);
if (ins) for (let i in ins) ins[i].updater.enqueueForceUpdate(ins[i])
}
}

View File

@ -94,8 +94,9 @@ class GoogleTranslateOption {
settingsitems = settingsitems.concat(this.createSelects(false));
for (let key in settings) settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSwitch, {
for (let key in settings) settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
@ -297,7 +298,7 @@ class GoogleTranslateOption {
className: BDFDB.disCN.textareapickerbuttoncontainer,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ChannelTextAreaButton, {
className: ["translate-button", this.translating ? "translating-active" : null, BDFDB.disCN.textareapickerbutton].filter(n => n).join(" "),
iconSVG: `<svg version="1.1" xmlns="http://www.w3.org/2000/svg" class="${BDFDB.disCN.textareaicon}" viewBox="0 0 22 22" fill="currentColor"><path d="M 19.794, 3.299 H 9.765 L 8.797, 0 h -6.598 C 0.99, 0, 0, 0.99, 0, 2.199 V 16.495 c 0, 1.21, 0.99, 2.199, 2.199, 2.199 H 9.897 l 1.1, 3.299 H 19.794 c 1.21, 0, 2.199 -0.99, 2.199 -2.199 V 5.498 C 21.993, 4.289, 21.003, 3.299, 19.794, 3.299 z M 5.68, 13.839 c -2.48, 0 -4.492 -2.018 -4.492 -4.492 s 2.018 -4.492, 4.492 -4.492 c 1.144, 0, 2.183, 0.407, 3.008, 1.171 l 0.071, 0.071 l -1.342, 1.298 l -0.066 -0.06 c -0.313 -0.297 -0.858 -0.643 -1.671 -0.643 c -1.441, 0 -2.612, 1.193 -2.612, 2.661 c 0, 1.468, 1.171, 2.661, 2.612, 2.661 c 1.507, 0, 2.161 -0.962, 2.337 -1.606 h -2.43 v -1.704 h 4.344 l 0.016, 0.077 c 0.044, 0.231, 0.06, 0.434, 0.06, 0.665 C 10.001, 12.036, 8.225, 13.839, 5.68, 13.839 z M 11.739, 9.979 h 4.393 c 0, 0 -0.374, 1.446 -1.715, 3.008 c -0.588 -0.676 -0.995 -1.336 -1.254 -1.864 h -1.089 L 11.739, 9.979 z M 13.625, 13.839 l -0.588, 0.583 l -0.72 -2.452 C 12.685, 12.63, 13.13, 13.262, 13.625, 13.839 z M 20.893, 19.794 c 0, 0.605 -0.495, 1.1 -1.1, 1.1 H 12.096 l 2.199 -2.199 l -0.896 -3.041 l 1.012 -1.012 l 2.953, 2.953 l 0.803 -0.803 l -2.975 -2.953 c 0.99 -1.138, 1.759 -2.474, 2.106 -3.854 h 1.397 V 8.841 H 14.697 v -1.144 h -1.144 v 1.144 H 11.398 l -1.309 -4.443 H 19.794 c 0.605, 0, 1.1, 0.495, 1.1, 1.1 V 19.794 z"/></svg>`
iconSVG: `<svg x="0" y="0" class="${BDFDB.disCN.textareaicon}" aria-hidden="false" width="22" height="22" viewBox="0 0 22 22" fill="currentColor"><path d="M 19.794, 3.299 H 9.765 L 8.797, 0 h -6.598 C 0.99, 0, 0, 0.99, 0, 2.199 V 16.495 c 0, 1.21, 0.99, 2.199, 2.199, 2.199 H 9.897 l 1.1, 3.299 H 19.794 c 1.21, 0, 2.199 -0.99, 2.199 -2.199 V 5.498 C 21.993, 4.289, 21.003, 3.299, 19.794, 3.299 z M 5.68, 13.839 c -2.48, 0 -4.492 -2.018 -4.492 -4.492 s 2.018 -4.492, 4.492 -4.492 c 1.144, 0, 2.183, 0.407, 3.008, 1.171 l 0.071, 0.071 l -1.342, 1.298 l -0.066 -0.06 c -0.313 -0.297 -0.858 -0.643 -1.671 -0.643 c -1.441, 0 -2.612, 1.193 -2.612, 2.661 c 0, 1.468, 1.171, 2.661, 2.612, 2.661 c 1.507, 0, 2.161 -0.962, 2.337 -1.606 h -2.43 v -1.704 h 4.344 l 0.016, 0.077 c 0.044, 0.231, 0.06, 0.434, 0.06, 0.665 C 10.001, 12.036, 8.225, 13.839, 5.68, 13.839 z M 11.739, 9.979 h 4.393 c 0, 0 -0.374, 1.446 -1.715, 3.008 c -0.588 -0.676 -0.995 -1.336 -1.254 -1.864 h -1.089 L 11.739, 9.979 z M 13.625, 13.839 l -0.588, 0.583 l -0.72 -2.452 C 12.685, 12.63, 13.13, 13.262, 13.625, 13.839 z M 20.893, 19.794 c 0, 0.605 -0.495, 1.1 -1.1, 1.1 H 12.096 l 2.199 -2.199 l -0.896 -3.041 l 1.012 -1.012 l 2.953, 2.953 l 0.803 -0.803 l -2.975 -2.953 c 0.99 -1.138, 1.759 -2.474, 2.106 -3.854 h 1.397 V 8.841 H 14.697 v -1.144 h -1.144 v 1.144 H 11.398 l -1.309 -4.443 H 19.794 c 0.605, 0, 1.1, 0.495, 1.1, 1.1 V 19.794 z"/></svg>`
}),
width: 400,
padding: 10,

View File

@ -3,7 +3,7 @@
class OldTitleBar {
getName () {return "OldTitleBar";}
getVersion () {return "1.5.9";}
getVersion () {return "1.6.0";}
getAuthor () {return "DevilBro";}
@ -11,14 +11,14 @@ class OldTitleBar {
constructor () {
this.changelog = {
"fixed":[["Activity Page","Fixed the issue where no icosn woud be added on the activity page"]]
"improved":[["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]]
};
this.patchModules = {
"HeaderBar":["componentDidMount","componentDidUpdate"],
"HeaderBarContainer":["componentDidMount","componentDidUpdate"],
"StandardSidebarView":["componentDidMount","componentWillUnmount"],
"AuthWrapper":["componentDidMount","componentWillUnmount"]
App: "render",
HeaderBarContainer: "render",
StandardSidebarView: "render",
AuthWrapper: "render"
};
}
@ -26,65 +26,45 @@ class OldTitleBar {
this.patched = false;
this.css = `
.hidden-by-OTB ${BDFDB.dotCN.titlebar},
.hidden-by-OTB ${BDFDB.dotCN.titlebar} + ${BDFDB.dotCNS.app + BDFDB.dotCN.splashbackground}:before {
.OTB-enabled ${BDFDB.dotCN.splashbackground}:before {
display: none !important;
}
.hidden-by-OTB .platform-osx ${BDFDB.dotCN.guildswrapper} {
.platform-osx.OTB-enabled ${BDFDB.dotCN.guildswrapper} {
margin-top: 0;
}
.hidden-by-OTB .platform-osx ${BDFDB.dotCN.guildsscroller} {
.platform-osx.OTB-enabled ${BDFDB.dotCN.guildsscroller} {
padding-top: 10px;
}
.OTB-toolbar {
flex: 1 1 auto;
justify-content: flex-end;
}
body:not(.settingsTitlebarOTB-added) ${BDFDB.dotCN.channelheaderheaderbar} {
.OTB-settingsToolbar {
position: absolute;
top: 0;
right: 0;
padding: 10px;
z-index: 2;
-webkit-app-region: drag !important;
}
.OTB-enabled ${BDFDB.dotCN.splashbackground} .OTB-settingsToolbar {
background: rgba(0, 0, 0, 0.3);
border-radius: 0 0 0 5px;
}
${BDFDB.dotCN.channelheaderheaderbar} {
-webkit-app-region: drag !important;
}
${BDFDB.dotCN.channelheaderheaderbar} *,
${BDFDB.dotCN.contextmenu} * {
-webkit-app-region: no-drag !important;
}
.settingsTitlebarOTB {
position: relative;
z-index: 1000;
padding: 10px;
-webkit-app-region: drag;
}`;
this.dividerMarkup = `<div class="buttonOTB dividerOTB ${BDFDB.disCN.channelheaderdivider}"></div>`;
this.reloadButtonMarkup =
`<div class="${BDFDB.disCNS.channelheadericonwrapper + BDFDB.disCN.channelheadericonclickable} buttonOTB reloadButtonOTB">
<svg class="${BDFDB.disCN.channelheadericon}" xmlns="http://www.w3.org/2000/svg">
<path fill="currentColor" stroke="none" transform="translate(4,4)" d="M17.061,7.467V0l-2.507,2.507C13.013,0.96,10.885,0,8.528,0C3.813,0,0.005,3.819,0.005,8.533s3.808,8.533,8.523,8.533c3.973,0,7.301-2.72,8.245-6.4h-2.219c-0.88,2.485-3.237,4.267-6.027,4.267c-3.536,0-6.4-2.864-6.4-6.4s2.864-6.4,6.4-6.4c1.765,0,3.349,0.736,4.507,1.893l-3.44,3.44H17.061z"/>
</svg>
</div>`;
this.minButtonMarkup =
`<div class="${BDFDB.disCNS.channelheadericonwrapper + BDFDB.disCN.channelheadericonclickable} buttonOTB minButtonOTB">
<svg class="${BDFDB.disCN.channelheadericon}" xmlns="http://www.w3.org/2000/svg" width="26" height="26">
<path stroke-width="2" stroke="currentColor" fill="none" d="M6 18 l13 0"/>
</svg>
</div>`;
this.maxButtonMarkup =
`<div class="${BDFDB.disCNS.channelheadericonwrapper + BDFDB.disCN.channelheadericonclickable} buttonOTB maxButtonOTB">
<svg class="${BDFDB.disCN.channelheadericon}" xmlns="http://www.w3.org/2000/svg" width="26" height="26"><g></g></svg>
</div>`;
this.maxButtonInnerMin = `<path stroke-width="2" stroke="currentColor" fill="none" d="M6 6 l13 0 l0 13 l-13 0 l0 -13"/>`;
this.maxButtonInnerMax = `<path stroke-width="2" stroke="currentColor" fill="none" d="M6 9 l10 0 l0 10 l-10 0 l0 -10 m3 -3 l10 0 l0 10"/>`;
this.closeButtonMarkup =
`<div class="${BDFDB.disCNS.channelheadericonwrapper + BDFDB.disCN.channelheadericonclickable} buttonOTB closeButtonOTB">
<svg class="${BDFDB.disCN.channelheadericon}" xmlns="http://www.w3.org/2000/svg" width="26" height="26">
<path stroke-width="2" stroke="currentColor" fill="none" d="M6 6 l13 13 m0 -13 l-13 13"/>
</svg>
</div>`;
this.defaults = {
settings: {
displayNative: {value:!!document.querySelector(".platform-linux"), description:"Displays the native Title Bar."},
@ -98,32 +78,32 @@ class OldTitleBar {
getSettingsPanel () {
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
let settings = BDFDB.DataUtils.get(this, "settings");
var settingshtml = `<div class="${this.name}-settings BDFDB-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.titlesize18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</div><div class="BDFDB-settings-inner">`;
for (let key in settings) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch${key == "displayNative" ? " nativetitlebar-switch" : ""}"${settings[key] ? " checked" : ""}></div></div>`;
}
settingshtml += `</div></div>`;
let settingspanel = BDFDB.DOMUtils.create(settingshtml);
BDFDB.initElements(settingspanel, this);
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".nativetitlebar-switch", e => {
if (this.patchMainScreen(e.currentTarget.checked)) {
this.patched = !this.patched;
let notifybar = document.querySelector("#OldTitleBarNotifyBar");
if (notifybar) notifybar.querySelector(BDFDB.dotCN.noticedismiss).click();
if (this.patched) {
notifybar = BDFDB.NotificationUtils.notice("Changed nativebar settings, relaunch to see changes:", {type:"danger",btn:"Relaunch",id:"OldTitleBarNotifyBar"});
notifybar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", () => {
BDFDB.LibraryRequires.electron.remote.app.relaunch();
BDFDB.LibraryRequires.electron.remote.app.quit();
});
let settingsitems = [];
for (let key in settings) settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key],
onChange: key == "displayNative" ? value => {
if (this.patchMainScreen(value)) {
this.patched = !this.patched;
let notifybar = document.querySelector("#OldTitleBarNotifyBar");
if (notifybar) notifybar.querySelector(BDFDB.dotCN.noticedismiss).click();
if (this.patched) {
notifybar = BDFDB.NotificationUtils.notice("Changed nativebar settings, relaunch to see changes:", {type:"danger",btn:"Relaunch",id:"OldTitleBarNotifyBar"});
notifybar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", () => {
BDFDB.LibraryRequires.electron.remote.app.relaunch();
BDFDB.LibraryRequires.electron.remote.app.quit();
});
}
}
}
});
return settingspanel;
} : null
}));
return BDFDB.PluginUtils.createSettingsPanel(this, settingsitems);
}
//legacy
@ -156,14 +136,14 @@ class OldTitleBar {
BDFDB.PluginUtils.init(this);
BDFDB.ListenerUtils.add(this, window, "resize", e => {
this.changeMaximizeButtons();
BDFDB.ModuleUtils.forceAllUpdates(this, ["HeaderBarContainer", "StandardSidebarView"]);
});
this.window = BDFDB.LibraryRequires.electron.remote.getCurrentWindow();
this.patchMainScreen(BDFDB.DataUtils.get(this, "settings", "displayNative"));
BDFDB.DOMUtils.addClass([document.body,document.querySelector(BDFDB.dotCN.titlebar)], "hidden-by-OTB");
BDFDB.DOMUtils.addClass(document.documentElement, "OTB-enabled");
BDFDB.ModuleUtils.forceAllUpdates(this);
}
@ -175,9 +155,9 @@ class OldTitleBar {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
BDFDB.DOMUtils.remove(".headerbarOTB", ".settingsTitlebarOTB");
BDFDB.ModuleUtils.forceAllUpdates(this);
BDFDB.DOMUtils.removeClassFromDOM("hidden-by-OTB", "settingsTitlebarOTB-added");
BDFDB.DOMUtils.removeClassFromDOM("OTB-enabled");
BDFDB.PluginUtils.clear(this);
}
@ -186,82 +166,99 @@ class OldTitleBar {
// begin of own functions
processHeaderBar (instance, wrapper, returnvalue) {
this.addTitleBar();
}
processHeaderBarContainer (instance, wrapper, returnvalue) {
this.addTitleBar();
}
processStandardSidebarView (instance, wrapper, returnvalue, methodnames) {
this.processAuthWrapper(instance, wrapper, returnvalue, methodnames);
}
processAuthWrapper (instance, wrapper, returnvalue, methodnames) {
if (methodnames.includes("componentDidMount")) {
this.addSettingsTitleBar(wrapper);
}
else if (methodnames.includes("componentWillUnmount")) {
BDFDB.DOMUtils.remove(".settingsTitlebarOTB");
BDFDB.DOMUtils.removeClass(document.body, "settingsTitlebarOTB-added");
this.addTitleBar();
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
BDFDB.ModuleUtils.forceAllUpdates(this, ["HeaderBarContainer", "StandardSidebarView"]);
}
}
addTitleBar () {
BDFDB.DOMUtils.remove(".headerbarOTB");
let settings = BDFDB.DataUtils.get(this, "settings");
if (BDFDB.DataUtils.get(this, "settings", "addOldBar")) {
var headerbar = BDFDB.DOMUtils.create(`<span class="headerbarOTB ${BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCN.nowrap}"></span>`);
this.createButtons(headerbar);
let headerbaricon = document.querySelector(BDFDB.dotCN.channelheaderchildren);
if (headerbaricon) headerbaricon.parentElement.appendChild(headerbar);
this.changeMaximizeButtons();
}
processApp (e) {
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["type",["WINDOWS", "MACOS"]]]});
if (index > -1) children[index] = null;
}
addSettingsTitleBar (settingspane) {
BDFDB.DOMUtils.remove(".settingsTitlebarOTB");
if (BDFDB.DataUtils.get(this, "settings", "addToSettings")) {
BDFDB.DOMUtils.addClass(document.body, "settingsTitlebarOTB-added");
var settingsbar = BDFDB.DOMUtils.create(`<div class="settingsTitlebarOTB ${BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifyend + BDFDB.disCNS.aligncenter + BDFDB.disCN.nowrap}"></div>`);
this.createButtons(settingsbar);
settingspane.parentElement.appendChild(settingsbar);
this.changeMaximizeButtons();
}
}
createButtons (bar) {
if (BDFDB.DataUtils.get(this, "settings", "reloadButton")) {
bar.appendChild(BDFDB.DOMUtils.create(this.dividerMarkup));
var reloadbutton = BDFDB.DOMUtils.create(this.reloadButtonMarkup);
bar.appendChild(reloadbutton);
var reloadbuttonicon = reloadbutton.querySelector(BDFDB.dotCN.channelheadericon);
reloadbuttonicon.addEventListener("click", () => {this.window.reload();});
reloadbuttonicon.addEventListener("mouseenter", e => {
BDFDB.TooltipUtils.create(reloadbuttonicon, "Reload", {type:"bottom",selector:"reload-button-tooltip"});
processHeaderBarContainer (e) {
if (!BDFDB.DataUtils.get(this, "settings", "addOldBar")) return;
let children = BDFDB.ReactUtils.getValue(e.returnvalue, "props.toolbar.props.children");
if (!children) {
let [oldToolbarParent, oldToolbarIndex] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["className", "OTB-toolbar"]]});
if (oldToolbarIndex > -1) oldToolbarParent.splice(oldToolbarIndex, 1);
let toolbar = BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCNS.channelheadertoolbar + "OTB-toolbar",
children: []
});
e.returnvalue.props.children.push(toolbar);
children = toolbar.props.children;
}
bar.appendChild(BDFDB.DOMUtils.create(this.dividerMarkup));
var minbutton = BDFDB.DOMUtils.create(this.minButtonMarkup);
bar.appendChild(minbutton);
minbutton.querySelector(BDFDB.dotCN.channelheadericon).addEventListener("click", () => {this.window.minimize();});
var maxbutton = BDFDB.DOMUtils.create(this.maxButtonMarkup);
bar.appendChild(maxbutton);
maxbutton.querySelector(BDFDB.dotCN.channelheadericon).addEventListener("click", () => {
if (this.isMaximized()) this.window.unmaximize();
else this.window.maximize();
});
var closebutton = BDFDB.DOMUtils.create(this.closeButtonMarkup);
bar.appendChild(closebutton);
closebutton.querySelector(BDFDB.dotCN.channelheadericon).addEventListener("click", () => {this.window.close();});
if (BDFDB.DOMUtils.containsClass(bar, "settingsTitlebarOTB")) BDFDB.DOMUtils.remove(bar.querySelector(".dividerOTB"));
this.injectButtons(children, true);
}
changeMaximizeButtons () {
var innerHTML = this.isMaximized() ? this.maxButtonInnerMax : this.maxButtonInnerMin;
document.querySelectorAll(".maxButtonOTB g").forEach(g => {g.innerHTML = innerHTML;});
processStandardSidebarView (e) {
if (!BDFDB.ArrayUtils.is(e.returnvalue.props.children)) e.returnvalue.props.children = [e.returnvalue.props.children];
this.injectSettingsToolbar(e.returnvalue.props.children);
}
processAuthWrapper (e) {
if (!BDFDB.ArrayUtils.is(e.returnvalue.props.children)) e.returnvalue.props.children = [e.returnvalue.props.children];
this.injectSettingsToolbar(e.returnvalue.props.children, true);
}
injectSettingsToolbar (children, fixed) {
if (!BDFDB.DataUtils.get(this, "settings", "addToSettings")) return;
let toolbar = BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCNS.channelheadertoolbar + "OTB-settingsToolbar",
children: [],
style: fixed ? {position: "fixed"} : null
});
this.injectButtons(toolbar.props.children);
children.push(toolbar);
}
injectButtons (children, addFirstDivider) {
if (addFirstDivider) children.push(BDFDB.ReactUtils.createElement("div", {className: BDFDB.disCN.channelheaderdivider}))
if (BDFDB.DataUtils.get(this, "settings", "reloadButton")) {
children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: BDFDB.LanguageUtils.LanguageStrings.ERRORS_RELOAD,
tooltipConfig: {type: "bottom"},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCNS.channelheadericonwrapper + BDFDB.disCN.channelheadericonclickable,
onClick: _ => {this.window.reload();},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCNS.channelheadericon + "OTB-reloadButton",
iconSVG: `<svg><path fill="currentColor" stroke="none" transform="translate(3,4)" d="M 17.061, 7.467 V 0 l -2.507, 2.507 C 13.013, 0.96, 10.885, 0, 8.528, 0 C 3.813, 0, 0.005, 3.819, 0.005, 8.533 s 3.808, 8.533, 8.523, 8.533 c 3.973, 0, 7.301 -2.72, 8.245 -6.4 h -2.219 c -0.88, 2.485 -3.237, 4.267 -6.027, 4.267 c -3.536, 0 -6.4 -2.864 -6.4 -6.4 s 2.864 -6.4, 6.4 -6.4 c 1.765, 0, 3.349, 0.736, 4.507, 1.893 l -3.44, 3.44 H 17.061 z"/></svg>`
})
})
}));
children.push(BDFDB.ReactUtils.createElement("div", {className: BDFDB.disCN.channelheaderdivider}));
};
children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCNS.channelheadericonwrapper + BDFDB.disCN.channelheadericonclickable,
onClick: _ => {this.window.minimize();},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCNS.channelheadericon + "OTB-minButton",
iconSVG: `<svg width="26" height="26"><path stroke-width="2" stroke="currentColor" fill="none" d="M6 18 l13 0"/></svg>`
})
}));
children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCNS.channelheadericonwrapper + BDFDB.disCN.channelheadericonclickable,
onClick: _ => {
if (this.isMaximized()) this.window.unmaximize();
else this.window.maximize();
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCNS.channelheadericon + "OTB-maxButton",
iconSVG: this.isMaximized() ? `<svg width="26" height="26"><path stroke-width="2" stroke="currentColor" fill="none" d="M6 9 l10 0 l0 10 l-10 0 l0 -10 m3 -3 l10 0 l0 10"/></svg>` : `<svg width="26" height="26"><path stroke-width="2" stroke="currentColor" fill="none" d="M6 6 l13 0 l0 13 l-13 0 l0 -13"/></svg>`
})
}));
children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCNS.channelheadericonwrapper + BDFDB.disCN.channelheadericonclickable,
onClick: _ => {this.window.close();},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCNS.channelheadericon + "OTB-closeButton",
iconSVG: `<svg width="26" height="26"><path stroke-width="2" stroke="currentColor" fill="none" d="M6 6 l13 13 m0 -13 l-13 13"/></svg>`
})
}));
}
isMaximized () {

View File

@ -65,8 +65,9 @@ class OwnerTag {
settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
}));
for (let key in settings) (!this.defaults.settings[key].inner ? settingsitems : inneritems).push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSwitch, {
for (let key in settings) (!this.defaults.settings[key].inner ? settingsitems : inneritems).push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,