new class normalizer and social patch
This commit is contained in:
parent
858a86ef53
commit
faa4747f42
11
css/main.css
11
css/main.css
|
@ -1,5 +1,5 @@
|
|||
/*New loader*/
|
||||
.bd-logo,
|
||||
|
||||
.bd-loaderv2 {
|
||||
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+IDwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyBoZWlnaHQ9IjEwMCUiIHN0eWxlPSJmaWxsLXJ1bGU6ZXZlbm9kZDtjbGlwLXJ1bGU6ZXZlbm9kZDtzdHJva2UtbGluZWNhcDpyb3VuZDtzdHJva2UtbGluZWpvaW46cm91bmQ7IiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWw6c3BhY2U9InByZXNlcnZlIiB3aWR0aD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMjAwMCAyMDAwIj4gICAgPG1ldGFkYXRhIC8+ICAgIDxkZWZzPiAgICAgICAgPGZpbHRlciBpZD0ic2hhZG93MSI+ICAgICAgICA8ZmVEcm9wU2hhZG93IGR4PSIyMCIgZHk9IjAiIHN0ZERldmlhdGlvbj0iMjAiIGZsb29kLWNvbG9yPSJyZ2JhKDAsMCwwLDAuMzUpIi8+ICAgICAgICA8L2ZpbHRlcj4gICAgICAgIDxmaWx0ZXIgaWQ9InNoYWRvdzIiPiAgICAgICAgPGZlRHJvcFNoYWRvdyBkeD0iMTUiIGR5PSIwIiBzdGREZXZpYXRpb249IjIwIiBmbG9vZC1jb2xvcj0icmdiYSgyNTUsMjU1LDI1NSwwLj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1KzQ5MC40NDJDMTEwOC45NSs0OTAuNDQyKzExMDguOTUrODM1LjM0Mis4MzQuNDUrODM1LjM0Mkw2NjQuNjUrODM1LjM0Mkw2NjQuNjUrMTE2NC44NEw4MzQuNDUrMTE2NC44NEM5MjMuOTMyKzExNjQuODQrOTg0LjI0NCsxMjAxLjQ4KzEwMTUuMzkrMTI1MC44N0MxMDc5Ljc4KzEzNTMrMTAxOS40NysxNTA5LjY0KzgzNC40NSsxNTA5LjY0TDEzNS40NSsxNTA5LjY0TDEzNS40NSsxODY0LjU0TDgyNi42NSsxODY0LjU0QzExODIuOTUrMTg2NC41NCsxNDU5LjQ1KzE3MjEuOTQrMTQ2OS4yNSsxMzY4LjU0QzE0NjkuMjUrMTIwNS45NCsxNDI0Ljc1KzEwODQuNDQrMTM0Ni4zNSs5OTkuOTQyQzE0MjQuNzUrOTE1LjU0MisxNDY5LjI1Kzc5NC4wNDIrMTQ2OS4yNSs2MzEuNDQyWiIgZmlsbD0iI0ZGRkZGRiIgb3BhY2l0eT0iMSIvPiAgICA8L2c+PC9zdmc+);
|
||||
}
|
||||
|
@ -22,6 +22,15 @@
|
|||
}
|
||||
/* // */
|
||||
|
||||
.bd-social-logo {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.bd-social-link:hover .bd-social-logo {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
|
||||
.bd-reload {
|
||||
cursor: pointer;
|
||||
vertical-align: top;
|
||||
|
|
File diff suppressed because one or more lines are too long
314
js/main.js
314
js/main.js
|
@ -181,7 +181,7 @@ window.bdPluginStorage = class bdPluginStorage {
|
|||
|
||||
var settingsPanel, emoteModule, quickEmoteMenu, voiceMode, pluginModule, themeModule, dMode, publicServersModule;
|
||||
var minSupportedVersion = "0.3.0";
|
||||
var bbdVersion = "0.2.3";
|
||||
var bbdVersion = "0.2.4";
|
||||
|
||||
|
||||
var mainCore;
|
||||
|
@ -273,8 +273,6 @@ function Core(config) {
|
|||
window.bdConfig = config;
|
||||
}
|
||||
|
||||
var classNormalizer;
|
||||
|
||||
Core.prototype.init = async function() {
|
||||
if (bdConfig.version < minSupportedVersion) {
|
||||
this.alert("Not Supported", "BetterDiscord v" + bdConfig.version + " (your version)" + " is not supported by the latest js (" + bbdVersion + ").<br><br> Please download the latest version from <a href='https://github.com/rauenzi/BetterDiscordApp/releases/latest' target='_blank'>GitHub</a>");
|
||||
|
@ -290,7 +288,6 @@ Core.prototype.init = async function() {
|
|||
|
||||
Utils.log("Initializing Settings");
|
||||
this.initSettings();
|
||||
classNormalizer = new ClassNormalizer();
|
||||
emoteModule = new EmoteModule();
|
||||
quickEmoteMenu = new QuickEmoteMenu();
|
||||
Utils.log("Initializing EmoteModule");
|
||||
|
@ -300,13 +297,14 @@ Core.prototype.init = async function() {
|
|||
quickEmoteMenu.init();
|
||||
});
|
||||
publicServersModule = new V2_PublicServers();
|
||||
|
||||
|
||||
voiceMode = new VoiceMode();
|
||||
dMode = new devMode();
|
||||
|
||||
|
||||
this.injectExternals();
|
||||
|
||||
await this.checkForGuilds();
|
||||
BDV2.initialize();
|
||||
Utils.log("Updating Settings");
|
||||
settingsPanel = new V2_SettingsPanel();
|
||||
settingsPanel.updateSettings();
|
||||
|
@ -339,20 +337,12 @@ Core.prototype.init = async function() {
|
|||
Utils.log("Collecting Startup Errors");
|
||||
this.showContentErrors({plugins: bdpluginErrors, themes: bdthemeErrors});
|
||||
}
|
||||
|
||||
if (!DataStore.getBDData("RNMAnnouncement")) {
|
||||
DataStore.setBDData("RNMAnnouncement", true);
|
||||
this.alert("Significant Changes", `
|
||||
The lastest release of BBD has made a lot of improvements including being able to automatically load, unload, and reload plugins and themes.<br /><br />
|
||||
If you had the RestartNoMore plugin, I suggest removing it (or turning off BBD's loader in settings) so things aren't being loaded multiple times.
|
||||
`);
|
||||
}
|
||||
};
|
||||
|
||||
Core.prototype.checkForGuilds = function() {
|
||||
return new Promise(resolve => {
|
||||
const checkForGuilds = function() {
|
||||
if (document.querySelectorAll(`.${BDV2.guildClasses.guilds} .${BDV2.guildClasses.guild}`).length > 0) return resolve(bdConfig.deferLoaded = true);
|
||||
if (document.querySelectorAll(`.${BDV2.guildClasses.guilds.split(" ")[0]} .${BDV2.guildClasses.guild.split(" ")[0]}`).length > 0) return resolve(bdConfig.deferLoaded = true);
|
||||
setTimeout(checkForGuilds, 100);
|
||||
};
|
||||
$(document).ready(function () {
|
||||
|
@ -850,7 +840,7 @@ EmoteModule.prototype.loadEmoteData = async function(emoteInfo) {
|
|||
_fs.unlinkSync(file);
|
||||
}
|
||||
|
||||
if (!settingsCookie["fork-es-3"]) return quickEmoteMenu.init();
|
||||
if (!settingsCookie["fork-es-3"]) return;
|
||||
if (settingsCookie["fork-ps-2"]) mainCore.showToast("Downloading emotes in the background do not reload.", {type: "info"});
|
||||
|
||||
for (let e in emoteInfo) {
|
||||
|
@ -863,8 +853,6 @@ EmoteModule.prototype.loadEmoteData = async function(emoteInfo) {
|
|||
|
||||
try { _fs.writeFileSync(file, JSON.stringify(window.bdEmotes), "utf8"); }
|
||||
catch (err) { Utils.err("[Emotes] Could not save emote data.", err); }
|
||||
|
||||
quickEmoteMenu.init();
|
||||
};
|
||||
|
||||
EmoteModule.prototype.downloadEmotes = function(emoteMeta) {
|
||||
|
@ -2116,89 +2104,115 @@ devMode.prototype.getSelector = function(element) {
|
|||
};
|
||||
|
||||
|
||||
var ClassNormalizer = class ClassNormalizer {
|
||||
constructor() {
|
||||
this.classFormat = new RegExp(`^(?!da-)[A-Za-z]+-([A-Za-z]|[0-9]|-|_){6}$`);
|
||||
this.normFormat = new RegExp(`^(?!da-)(?:-?[a-z])+$`);
|
||||
this.mainObserver = new MutationObserver((changes) => {
|
||||
for (let c = 0; c < changes.length; c++) {
|
||||
const change = changes[c];
|
||||
const elements = change.addedNodes;
|
||||
if (!elements) continue;
|
||||
for (let n = 0; n < elements.length; n++) {
|
||||
if (!(elements[n] instanceof Element) || !elements[n].classList) continue;
|
||||
this.normalizeClasses(elements[n]);
|
||||
var ClassNormalizer = (() => {
|
||||
const normalizedPrefix = "da";
|
||||
const randClass = new RegExp(`^(?!${normalizedPrefix}-)((?:[A-Za-z]|[0-9]|-)+)-(?:[A-Za-z]|[0-9]|-|_){6}$`);
|
||||
|
||||
return new class ClassNormalizer {
|
||||
|
||||
stop() {
|
||||
if (!this.hasPatched) return;
|
||||
this.unpatchClassModules(BdApi.findAllModules(this.moduleFilter.bind(this)));
|
||||
this.revertElement(document.querySelector("#app-mount"));
|
||||
this.hasPatched = false;
|
||||
}
|
||||
|
||||
start() {
|
||||
if (this.hasPatched) return;
|
||||
this.patchClassModules(BdApi.findAllModules(this.moduleFilter.bind(this)));
|
||||
this.normalizeElement(document.querySelector("#app-mount"));
|
||||
this.hasPatched = true;
|
||||
}
|
||||
|
||||
patchClassModules(modules) {
|
||||
for (const module of modules) {
|
||||
this.patchClassModule(normalizedPrefix, module);
|
||||
}
|
||||
}
|
||||
|
||||
unpatchClassModules(modules) {
|
||||
for (const module of modules) {
|
||||
this.unpatchClassModule(normalizedPrefix, module);
|
||||
}
|
||||
}
|
||||
|
||||
shouldIgnore(value) {
|
||||
if (!isNaN(value)) return true;
|
||||
if (value.endsWith("px") || value.endsWith("ch") || value.endsWith("em") || value.endsWith("ms")) return true;
|
||||
if (value.startsWith("#") && (value.length == 7 || value.length == 4)) return true;
|
||||
if (value.includes("calc(") || value.includes("rgba")) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
moduleFilter(module) {
|
||||
if (typeof module !== "object" || Array.isArray(module)) return false;
|
||||
if (module.__esModule) return false;
|
||||
if (!Object.keys(module).length) return false;
|
||||
for (const baseClassName in module) {
|
||||
const value = module[baseClassName];
|
||||
if (typeof value !== "string") return false;
|
||||
if (this.shouldIgnore(value)) continue;
|
||||
if (value.split("-").length === 1) return false;
|
||||
if (!randClass.test(value.split(" ")[0])) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
patchClassModule(componentName, classNames) {
|
||||
for (const baseClassName in classNames) {
|
||||
const value = classNames[baseClassName];
|
||||
if (this.shouldIgnore(value)) continue;
|
||||
const classList = value.split(" ");
|
||||
for (const normalClass of classList) {
|
||||
const match = normalClass.match(randClass)[1];
|
||||
if (!match) continue; // Shouldn't ever happen since they passed the moduleFilter, but you never know
|
||||
const camelCase = match.split("-").map((s, i) => i ? s[0].toUpperCase() + s.slice(1) : s).join("");
|
||||
classNames[baseClassName] += ` ${componentName}-${camelCase}`;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.cache = {};
|
||||
this.isActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
stop() {
|
||||
if (!this.isActive) return;
|
||||
this.isActive = false;
|
||||
this.mainObserver.disconnect();
|
||||
this.revertClasses(document.querySelector("#app-mount"));
|
||||
}
|
||||
|
||||
start() {
|
||||
if (this.isActive) return;
|
||||
this.isActive = true;
|
||||
this.normalizeClasses(document.querySelector("#app-mount"));
|
||||
this.mainObserver.observe(document.querySelector("#app-mount"), {childList: true, subtree: true});
|
||||
}
|
||||
|
||||
toCamelCase(className) {
|
||||
return className.split("-").map((s, i) => i ? s[0].toUpperCase() + s.slice(1) : s).join("");
|
||||
}
|
||||
|
||||
isRandomizedClass(className) {
|
||||
return this.classFormat.test(className);
|
||||
}
|
||||
|
||||
isNormalClass(className) {
|
||||
return this.normFormat.test(className);
|
||||
}
|
||||
|
||||
normalizeClasses(element) {
|
||||
if (!(element instanceof Element)) return;
|
||||
if (element.children && element.children.length) this.normalizeClasses(element.children[0]);
|
||||
if (element.nextElementSibling) this.normalizeClasses(element.nextElementSibling);
|
||||
const classes = element.classList;
|
||||
const toAdd = [];
|
||||
for (let c = 0; c < classes.length; c++) {
|
||||
if (this.cache[classes[c]]) {
|
||||
toAdd.push(this.cache[classes[c]]);
|
||||
}
|
||||
else if (this.isNormalClass(classes[c])) {
|
||||
const newClass = "da-" + this.toCamelCase(classes[c]);
|
||||
toAdd.push(newClass);
|
||||
this.cache[classes[c]] = newClass;
|
||||
}
|
||||
else if (this.isRandomizedClass(classes[c])) {
|
||||
const newClass = "da-" + classes[c].split("-")[0];
|
||||
toAdd.push(newClass);
|
||||
this.cache[classes[c]] = newClass;
|
||||
unpatchClassModule(componentName, classNames) {
|
||||
for (const baseClassName in classNames) {
|
||||
const value = classNames[baseClassName];
|
||||
if (this.shouldIgnore(value)) continue;
|
||||
let newString = "";
|
||||
const classList = value.split(" ");
|
||||
for (const normalClass of classList) {
|
||||
if (normalClass.startsWith(`${componentName}-`)) continue;
|
||||
newString += ` ${normalClass}`;
|
||||
}
|
||||
classNames[baseClassName] = newString.trim();
|
||||
}
|
||||
}
|
||||
element.classList.add(...toAdd);
|
||||
}
|
||||
|
||||
revertClasses(element) {
|
||||
if (!(element instanceof Element)) return;
|
||||
if (element.children && element.children.length) this.revertClasses(element.children[0]);
|
||||
if (element.nextElementSibling) this.revertClasses(element.nextElementSibling);
|
||||
const classes = element.classList;
|
||||
const toRemove = [];
|
||||
for (let c = 0; c < classes.length; c++) {
|
||||
if (classes[c].startsWith("da-")) toRemove.push(classes[c]);
|
||||
normalizeElement(element) {
|
||||
if (!(element instanceof Element)) return;
|
||||
const classes = element.classList;
|
||||
for (let c = 0, clen = classes.length; c < clen; c++) {
|
||||
if (!randClass.test(classes[c])) continue;
|
||||
const match = classes[c].match(randClass)[1];
|
||||
const newClass = match.split("-").map((s, i) => i ? s[0].toUpperCase() + s.slice(1) : s).join("");
|
||||
element.classList.add(`${normalizedPrefix}-${newClass}`);
|
||||
}
|
||||
for (const child of element.children) this.normalizeElement(child);
|
||||
}
|
||||
element.classList.remove(...toRemove);
|
||||
}
|
||||
|
||||
};
|
||||
revertElement(element) {
|
||||
if (!(element instanceof Element)) return;
|
||||
if (element.children && element.children.length) this.revertElement(element.children[0]);
|
||||
if (element.nextElementSibling) this.revertElement(element.nextElementSibling);
|
||||
const classes = element.classList;
|
||||
const toRemove = [];
|
||||
for (let c = 0; c < classes.length; c++) {
|
||||
if (classes[c].startsWith(`${normalizedPrefix}-`)) toRemove.push(classes[c]);
|
||||
}
|
||||
element.classList.remove(...toRemove);
|
||||
}
|
||||
|
||||
};
|
||||
})();
|
||||
|
||||
|
||||
|
||||
|
@ -2403,61 +2417,22 @@ class V2 {
|
|||
this.getInternalInstance = e => e[Object.keys(e).find(k => k.startsWith("__reactInternalInstance"))];
|
||||
}
|
||||
|
||||
get messageClasses() {
|
||||
return this.WebpackModules.findByUniqueProperties(["message", "containerCozy"]) || {};
|
||||
initialize() {
|
||||
this.patchSocial();
|
||||
}
|
||||
|
||||
get guildClasses() {
|
||||
return this.WebpackModules.findByUniqueProperties(["guildsWrapper"]) || {
|
||||
guildsWrapper: "guilds-wrapper",
|
||||
scrollerWrap: "scroller-wrap",
|
||||
guilds: "guilds",
|
||||
friendsIcon: "friends-icon",
|
||||
homeIcon: "home-icon",
|
||||
guildPlaceholder: "guild-placeholder",
|
||||
guild: "guild",
|
||||
selected: "selected",
|
||||
unread: "unread",
|
||||
guildInner: "guild-inner",
|
||||
audio: "audio",
|
||||
video: "video",
|
||||
guildIcon: "guild-icon",
|
||||
badge: "badge",
|
||||
dms: "dms",
|
||||
guildSeparator: "guild-separator",
|
||||
guildsError: "guilds-error",
|
||||
guildsAdd: "guilds-add",
|
||||
guildsAddInner: "guilds-add-inner",
|
||||
unreadMentionsIndicatorBottom: "unread-mentions-indicator-bottom",
|
||||
unreadMentionsIndicatorTop: "unread-mentions-indicator-top",
|
||||
unreadMentionsBar: "unread-mentions-bar",
|
||||
unreadMentionBar: "unread-mention-bar"
|
||||
};
|
||||
}
|
||||
|
||||
get MessageContentComponent() {return BDV2.WebpackModules.find(m => m.defaultProps && m.defaultProps.hasOwnProperty("disableButtons"));}
|
||||
|
||||
get TimeFormatter() {return BDV2.WebpackModules.findByUniqueProperties(["dateFormat"]);}
|
||||
|
||||
get TooltipWrapper() {return BDV2.WebpackModules.find(m => m.prototype && m.prototype.showDelayed);}
|
||||
|
||||
get NativeModule() {return BDV2.WebpackModules.findByUniqueProperties(["setBadge"]);}
|
||||
|
||||
get Tooltips() {return BDV2.WebpackModules.find(m => m.hide && m.show && !m.search && !m.submit && !m.search && !m.activateRagingDemon && !m.dismiss);}
|
||||
|
||||
get KeyGenerator() {return BDV2.WebpackModules.find(m => m.toString && /"binary"/.test(m.toString()));}
|
||||
|
||||
get reactComponent() {
|
||||
return this.internal.react.Component;
|
||||
}
|
||||
|
||||
get react() {
|
||||
return this.internal.react;
|
||||
}
|
||||
|
||||
get reactDom() {
|
||||
return this.internal.reactDom;
|
||||
}
|
||||
get react() {return this.internal.react;}
|
||||
get reactDom() {return this.internal.reactDom;}
|
||||
get reactComponent() {return this.internal.react.Component;}
|
||||
|
||||
get messageClasses() {return this.WebpackModules.findByUniqueProperties(["message", "containerCozy"]);}
|
||||
get guildClasses() {return this.WebpackModules.findByUniqueProperties(["guildsWrapper"]);}
|
||||
get MessageContentComponent() {return this.WebpackModules.find(m => m.defaultProps && m.defaultProps.hasOwnProperty("disableButtons"));}
|
||||
get TimeFormatter() {return this.WebpackModules.findByUniqueProperties(["dateFormat"]);}
|
||||
get TooltipWrapper() {return this.WebpackModules.find(m => m.prototype && m.prototype.showDelayed);}
|
||||
get NativeModule() {return this.WebpackModules.findByUniqueProperties(["setBadge"]);}
|
||||
get Tooltips() {return this.WebpackModules.find(m => m.hide && m.show && !m.search && !m.submit && !m.search && !m.activateRagingDemon && !m.dismiss);}
|
||||
get KeyGenerator() {return this.WebpackModules.find(m => m.toString && /"binary"/.test(m.toString()));}
|
||||
|
||||
parseSettings(cat) {
|
||||
return Object.keys(settings).reduce((arr, key) => {
|
||||
|
@ -2469,11 +2444,52 @@ class V2 {
|
|||
}, []);
|
||||
}
|
||||
|
||||
patchSocial() {
|
||||
if (this.socialPatch) return;
|
||||
const TabBar = BdApi.findModule(m => m.displayName == "TabBar");
|
||||
const Anchor = BdApi.findModule(m => m.displayName == "Anchor");
|
||||
if (!TabBar || !Anchor) return;
|
||||
this.socialPatch = BdApi.monkeyPatch(TabBar.prototype, "render", {after: (data) => {
|
||||
const children = data.returnValue.props.children;
|
||||
if (!children || !children.length) return;
|
||||
if (children[children.length - 1].type.displayName !== "SocialLinks") return;
|
||||
const original = children[children.length - 1].type;
|
||||
const newOne = function() {
|
||||
const returnVal = original(...arguments);
|
||||
returnVal.props.children.push(BdApi.React.createElement(Anchor, {className: "bd-social-link", href: "https://github.com/rauenzi/BetterDiscordApp", rel: "author", title: "BandagedBD", target: "_blank"},
|
||||
BdApi.React.createElement(BDLogo, {size: "16px", className: "bd-social-logo"})
|
||||
));
|
||||
return returnVal;
|
||||
};
|
||||
children[children.length - 1].type = newOne;
|
||||
}});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
var BDV2 = new V2();
|
||||
|
||||
class BDLogo extends BDV2.reactComponent {
|
||||
render() {
|
||||
return BDV2.react.createElement(
|
||||
"svg",
|
||||
{height: "100%", width: this.props.size || "16px", className: "bd-logo " + this.props.className, style: {fillRule: "evenodd", clipRule: "evenodd", strokeLinecap: "round", strokeLinejoin: "round"}, viewBox: "0 0 2000 2000"},
|
||||
BDV2.react.createElement("metadata", null),
|
||||
BDV2.react.createElement("defs", null,
|
||||
BDV2.react.createElement("filter", {id: "shadow1"}, BDV2.react.createElement("feDropShadow", {"dx": "20", "dy": "0", "stdDeviation": "20", "flood-color": "rgba(0,0,0,0.35)"})),
|
||||
BDV2.react.createElement("filter", {id: "shadow2"}, BDV2.react.createElement("feDropShadow", {"dx": "15", "dy": "0", "stdDeviation": "20", "flood-color": "rgba(255,255,255,0.15)"})),
|
||||
BDV2.react.createElement("filter", {id: "shadow3"}, BDV2.react.createElement("feDropShadow", {"dx": "10", "dy": "0", "stdDeviation": "20", "flood-color": "rgba(0,0,0,0.35)"}))
|
||||
),
|
||||
BDV2.react.createElement("g", null,
|
||||
BDV2.react.createElement("path", {style: {filter: "url(#shadow3)"}, d: "M1195.44+135.442L1195.44+135.442L997.6+136.442C1024.2+149.742+1170.34+163.542+1193.64+179.742C1264.34+228.842+1319.74+291.242+1358.24+365.042C1398.14+441.642+1419.74+530.642+1422.54+629.642L1422.54+630.842L1422.54+632.042C1422.54+773.142+1422.54+1228.14+1422.54+1369.14L1422.54+1370.34L1422.54+1371.54C1419.84+1470.54+1398.24+1559.54+1358.24+1636.14C1319.74+1709.94+1264.44+1772.34+1193.64+1821.44C1171.04+1837.14+1025.7+1850.54+1000+1863.54L1193.54+1864.54C1539.74+1866.44+1864.54+1693.34+1864.54+1296.64L1864.54+716.942C1866.44+312.442+1541.64+135.442+1195.44+135.442Z", fill: "#171717", opacity: "1"}),
|
||||
BDV2.react.createElement("path", {style: {filter: "url(#shadow2)"}, d: "M1695.54+631.442C1685.84+278.042+1409.34+135.442+1052.94+135.442L361.74+136.442L803.74+490.442L1060.74+490.442C1335.24+490.442+1335.24+835.342+1060.74+835.342L1060.74+1164.84C1150.22+1164.84+1210.53+1201.48+1241.68+1250.87C1306.07+1353+1245.76+1509.64+1060.74+1509.64L361.74+1863.54L1052.94+1864.54C1409.24+1864.54+1685.74+1721.94+1695.54+1368.54C1695.54+1205.94+1651.04+1084.44+1572.64+999.942C1651.04+915.542+1695.54+794.042+1695.54+631.442Z", fill: "#3E82E5", opacity: "1"}),
|
||||
BDV2.react.createElement("path", {style: {filter: "url(#shadow1)"}, d: "M1469.25+631.442C1459.55+278.042+1183.05+135.442+826.65+135.442L135.45+135.442L135.45+1004C135.45+1004+135.427+1255.21+355.626+1255.21C575.825+1255.21+575.848+1004+575.848+1004L577.45+490.442L834.45+490.442C1108.95+490.442+1108.95+835.342+834.45+835.342L664.65+835.342L664.65+1164.84L834.45+1164.84C923.932+1164.84+984.244+1201.48+1015.39+1250.87C1079.78+1353+1019.47+1509.64+834.45+1509.64L135.45+1509.64L135.45+1864.54L826.65+1864.54C1182.95+1864.54+1459.45+1721.94+1469.25+1368.54C1469.25+1205.94+1424.75+1084.44+1346.35+999.942C1424.75+915.542+1469.25+794.042+1469.25+631.442Z", fill: "#FFFFFF", opacity: "1"})
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BDEmote extends BDV2.reactComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
@ -3901,8 +3917,8 @@ class V2_SettingsPanel {
|
|||
mainCore.removeColoredText();
|
||||
}
|
||||
|
||||
if (_c["fork-ps-4"]) classNormalizer.start();
|
||||
else classNormalizer.stop();
|
||||
if (_c["fork-ps-4"]) ClassNormalizer.start();
|
||||
else ClassNormalizer.stop();
|
||||
|
||||
if (_c["fork-ps-5"]) {
|
||||
ContentManager.watchContent("plugin");
|
||||
|
@ -4282,7 +4298,7 @@ class V2_PublicServers {
|
|||
}
|
||||
|
||||
initialize() {
|
||||
let guilds = $(`.${BDV2.guildClasses.guilds}>:first-child`);
|
||||
let guilds = $(`.${BDV2.guildClasses.guilds.split(" ")[0]}>:first-child`);
|
||||
guilds.after(this.button);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue