stuff
This commit is contained in:
parent
b213fe1d7f
commit
c4f992fb1a
|
@ -420,6 +420,7 @@
|
||||||
"UserPopoutInfo": {"strings": [".hasCustomStatus", ".premiumGuildSince", "openPremiumSettings"]},
|
"UserPopoutInfo": {"strings": [".hasCustomStatus", ".premiumGuildSince", "openPremiumSettings"]},
|
||||||
"UserProfileModalHeader": {"strings": [".friendToken", ".additionalActionsIcon", "onMessage"]},
|
"UserProfileModalHeader": {"strings": [".friendToken", ".additionalActionsIcon", "onMessage"]},
|
||||||
"UserSummaryItem": {"protos": ["renderMoreUsers", "renderUsers", "renderIcon"]},
|
"UserSummaryItem": {"protos": ["renderMoreUsers", "renderUsers", "renderIcon"]},
|
||||||
|
"UserSettingsAppearance": {"protos": ["renderTheme", "renderDisplayMode", "renderMessageGroupSpacingSlider"]},
|
||||||
"UserThemedBanner": {"strings": [".showPremiumBadgeUpsell", ".isPremiumAtLeast", ".SETTINGS"]},
|
"UserThemedBanner": {"strings": [".showPremiumBadgeUpsell", ".isPremiumAtLeast", ".SETTINGS"]},
|
||||||
"UserThemedPopoutBody": {"strings": [".customStatusActivity", ".canDM", ".hidePersonalInformation"]},
|
"UserThemedPopoutBody": {"strings": [".customStatusActivity", ".canDM", ".hidePersonalInformation"]},
|
||||||
"UserThemedPopoutHeader": {"strings": [".avatarPositionPremiumNoBanner", "syncProfileThemeWithUserTheme"]},
|
"UserThemedPopoutHeader": {"strings": [".avatarPositionPremiumNoBanner", "syncProfileThemeWithUserTheme"]},
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* @name TimedLightDarkMode
|
* @name TimedLightDarkMode
|
||||||
* @author DevilBro
|
* @author DevilBro
|
||||||
* @authorId 278543574059057154
|
* @authorId 278543574059057154
|
||||||
* @version 1.1.3
|
* @version 1.1.4
|
||||||
* @description Adds a Time Slider to the Appearance Settings
|
* @description Adds a Time Slider to the Appearance Settings
|
||||||
* @invite Jx3TjNS
|
* @invite Jx3TjNS
|
||||||
* @donate https://www.paypal.me/MircoWittrien
|
* @donate https://www.paypal.me/MircoWittrien
|
||||||
|
@ -57,12 +57,11 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
} : (([Plugin, BDFDB]) => {
|
} : (([Plugin, BDFDB]) => {
|
||||||
var checkInterval, changeTimeout, disableChanging;
|
var checkInterval, changeTimeout, disableChanging;
|
||||||
var settings = {}, values = {};
|
|
||||||
|
|
||||||
return class TimedLightDarkMode extends Plugin {
|
return class TimedLightDarkMode extends Plugin {
|
||||||
onLoad () {
|
onLoad () {
|
||||||
this.defaults = {
|
this.defaults = {
|
||||||
settings: {
|
general: {
|
||||||
running: {value: true}
|
running: {value: true}
|
||||||
},
|
},
|
||||||
values: {
|
values: {
|
||||||
|
@ -71,16 +70,16 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.patchedModules = {
|
this.modulePatches = {
|
||||||
after: {
|
after: [
|
||||||
UserSettingsAppearance: "render"
|
"UserSettingsAppearance"
|
||||||
}
|
]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
onStart () {
|
onStart () {
|
||||||
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.AppearanceSettingsUtils, "updateTheme", {after: e => {
|
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.AppearanceSettingsUtils, "updateTheme", {after: e => {
|
||||||
if (settings.running) {
|
if (this.settings.general.running) {
|
||||||
BDFDB.TimeUtils.clear(changeTimeout);
|
BDFDB.TimeUtils.clear(changeTimeout);
|
||||||
disableChanging = true;
|
disableChanging = true;
|
||||||
changeTimeout = BDFDB.TimeUtils.timeout(_ => {
|
changeTimeout = BDFDB.TimeUtils.timeout(_ => {
|
||||||
|
@ -102,52 +101,49 @@ module.exports = (_ => {
|
||||||
|
|
||||||
processUserSettingsAppearance (e) {
|
processUserSettingsAppearance (e) {
|
||||||
let formItem = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "FormItem", props: [["title", BDFDB.LanguageUtils.LanguageStrings.THEME]]});
|
let formItem = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "FormItem", props: [["title", BDFDB.LanguageUtils.LanguageStrings.THEME]]});
|
||||||
if (formItem && formItem.props) {
|
if (!formItem || !formItem.props) return;
|
||||||
let slider;
|
let slider;
|
||||||
formItem.props.children = [
|
formItem.props.children = [
|
||||||
formItem.props.children,
|
formItem.props.children,
|
||||||
BDFDB.ReactUtils.createElement("div", {
|
BDFDB.ReactUtils.createElement("div", {
|
||||||
className: BDFDB.disCNS._timedlightdarkmodetimersettings + BDFDB.disCN.margintop20,
|
className: BDFDB.disCNS._timedlightdarkmodetimersettings + BDFDB.disCN.margintop20,
|
||||||
children: [
|
children: [
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
type: "Switch",
|
type: "Switch",
|
||||||
plugin: this,
|
plugin: this,
|
||||||
keys: ["settings", "running"],
|
keys: ["general", "running"],
|
||||||
value: settings.running,
|
value: this.settings.general.running,
|
||||||
label: `${BDFDB.LanguageUtils.LanguageStrings.THEME} Timer`,
|
label: `${BDFDB.LanguageUtils.LanguageStrings.THEME} Timer`,
|
||||||
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H5,
|
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H5,
|
||||||
childProps: {
|
childProps: {
|
||||||
checkedColor: BDFDB.DiscordConstants.Colors.STATUS_GREEN
|
checkedColor: BDFDB.DiscordConstants.Colors.STATUS_GREEN_600
|
||||||
},
|
},
|
||||||
onChange: (value, instance) => {
|
onChange: (value, instance) => {
|
||||||
this.startInterval();
|
this.startInterval();
|
||||||
if (slider) BDFDB.DOMUtils.toggleClass(slider, BDFDB.disCN.sliderdisabled, !value);
|
if (slider) BDFDB.DOMUtils.toggleClass(slider, BDFDB.disCN.sliderdisabled, !value);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
BDFDB.ReactUtils.elementToReact(BDFDB.DOMUtils.create(`<div class="${BDFDB.disCNS.slider + BDFDB.disCN.margintop20}${!settings.running ? (" " + BDFDB.disCN.sliderdisabled): ""}"><div class="${BDFDB.disCN.slidertrack}">${[["0%", "00:00"], ["12.5%", "03:00"], ["25%", "06:00"], ["37.5%", "09:00"], ["50%", "12:00"], ["62.5%", "15:00"], ["75%", "18:00"], ["87.5%", "21:00"], ["100%", "24:00"]].map(n => `<div class="${BDFDB.disCNS.slidermark + BDFDB.disCN.slidermarkabove}" style="left:${n[0]};"><div class="${BDFDB.disCN.slidermarkvalue}">${n[1]}</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div>`).join("")}</div><div class="${BDFDB.disCN.sliderbar}"><div class="${BDFDB.disCN.sliderbarfill}"></div></div><div class="${BDFDB.disCN.slidertrack}"><div class="${BDFDB.disCNS.slidergrabber + BDFDB.disCN._timedlightdarkmodetimergrabber}" timer="timer1" style="left: ${values.timer1}%;"></div><div class="${BDFDB.disCNS.slidergrabber + BDFDB.disCN._timedlightdarkmodetimergrabber}" timer="timer2" style="left: ${values.timer2}%;"></div><div class="${BDFDB.disCNS.slidergrabber + BDFDB.disCN._timedlightdarkmodedategrabber}" timer="current" style="left: ${this.getPercent(new Date())}%; cursor: help !important; height: 12px; margin-top: -7px;"></div></div></div>`), node => {
|
BDFDB.ReactUtils.elementToReact(BDFDB.DOMUtils.create(`<div class="${BDFDB.disCNS.slider + BDFDB.disCN.margintop20}${!this.settings.general.running ? (" " + BDFDB.disCN.sliderdisabled): ""}"><div class="${BDFDB.disCN.slidertrack}">${[["0%", "00:00"], ["12.5%", "03:00"], ["25%", "06:00"], ["37.5%", "09:00"], ["50%", "12:00"], ["62.5%", "15:00"], ["75%", "18:00"], ["87.5%", "21:00"], ["100%", "24:00"]].map(n => `<div class="${BDFDB.disCNS.slidermark + BDFDB.disCN.slidermarkabove}" style="left:${n[0]};"><div class="${BDFDB.disCN.slidermarkvalue}">${n[1]}</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div>`).join("")}</div><div class="${BDFDB.disCN.sliderbar}"><div class="${BDFDB.disCN.sliderbarfill}"></div></div><div class="${BDFDB.disCN.slidertrack}"><div class="${BDFDB.disCNS.slidergrabber + BDFDB.disCN._timedlightdarkmodetimergrabber}" timer="timer1" style="left: ${this.settings.values.timer1}%;"></div><div class="${BDFDB.disCNS.slidergrabber + BDFDB.disCN._timedlightdarkmodetimergrabber}" timer="timer2" style="left: ${this.settings.values.timer2}%;"></div><div class="${BDFDB.disCNS.slidergrabber + BDFDB.disCN._timedlightdarkmodedategrabber}" timer="current" style="left: ${this.getPercent(new Date())}%; cursor: help !important; height: 12px; margin-top: -7px;"></div></div></div>`), node => {
|
||||||
if (!Node.prototype.isPrototypeOf(node)) return;
|
if (!Node.prototype.isPrototypeOf(node)) return;
|
||||||
slider = node;
|
slider = node;
|
||||||
this.updateSlider(slider, values);
|
this.updateSlider(slider);
|
||||||
BDFDB.ListenerUtils.addToChildren(slider, "mousedown", BDFDB.dotCN._timedlightdarkmodetimergrabber, event => this.dragSlider(event.currentTarget));
|
BDFDB.ListenerUtils.addToChildren(slider, "mousedown", BDFDB.dotCN._timedlightdarkmodetimergrabber, event => this.dragSlider(event.currentTarget));
|
||||||
BDFDB.ListenerUtils.addToChildren(slider, "mouseenter", BDFDB.dotCN._timedlightdarkmodedategrabber, event => this.showCurrentTime(event.currentTarget));
|
BDFDB.ListenerUtils.addToChildren(slider, "mouseenter", BDFDB.dotCN._timedlightdarkmodedategrabber, event => this.showCurrentTime(event.currentTarget));
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||||
className: BDFDB.disCNS.margintop20 + BDFDB.disCN.marginbottom8
|
className: BDFDB.disCNS.margintop20 + BDFDB.disCN.marginbottom8
|
||||||
})
|
})
|
||||||
].flat(10).filter(n => n);
|
].flat(10).filter(n => n);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
startInterval () {
|
startInterval () {
|
||||||
BDFDB.TimeUtils.clear(checkInterval);
|
BDFDB.TimeUtils.clear(checkInterval);
|
||||||
settings = BDFDB.DataUtils.get(this, "settings");
|
|
||||||
values = BDFDB.DataUtils.get(this, "values");
|
|
||||||
disableChanging = false;
|
disableChanging = false;
|
||||||
if (settings.running) {
|
if (this.settings.general.running) {
|
||||||
let inverted = values.timer1 > values.timer2;
|
let inverted = this.settings.values.timer1 > this.settings.values.timer2;
|
||||||
let timer1LOW = this.getTime(values.timer1), timer2LOW = this.getTime(values.timer2);
|
let timer1LOW = this.getTime(this.settings.values.timer1), timer2LOW = this.getTime(this.settings.values.timer2);
|
||||||
let timer1HIGH = this.getHighTime(timer2LOW), timer2HIGH = this.getHighTime(timer1LOW);
|
let timer1HIGH = this.getHighTime(timer2LOW), timer2HIGH = this.getHighTime(timer1LOW);
|
||||||
let check = _ => {
|
let check = _ => {
|
||||||
if (disableChanging) return;
|
if (disableChanging) return;
|
||||||
|
@ -188,7 +184,7 @@ module.exports = (_ => {
|
||||||
|
|
||||||
BDFDB.DOMUtils.appendLocalStyle("disableTextSelection", `*{user-select: none !important;}`);
|
BDFDB.DOMUtils.appendLocalStyle("disableTextSelection", `*{user-select: none !important;}`);
|
||||||
|
|
||||||
let value = values[timer];
|
let value = this.settings.values[timer];
|
||||||
let sY = 0;
|
let sY = 0;
|
||||||
let sHalfW = BDFDB.DOMUtils.getRects(grabber).width/2;
|
let sHalfW = BDFDB.DOMUtils.getRects(grabber).width/2;
|
||||||
let sMinX = BDFDB.DOMUtils.getRects(track).left;
|
let sMinX = BDFDB.DOMUtils.getRects(track).left;
|
||||||
|
@ -209,19 +205,19 @@ module.exports = (_ => {
|
||||||
grabber.style.setProperty("left", value + "%");
|
grabber.style.setProperty("left", value + "%");
|
||||||
tooltipContent.innerText = this.getTime(value, true);
|
tooltipContent.innerText = this.getTime(value, true);
|
||||||
tooltip.update();
|
tooltip.update();
|
||||||
values[timer] = value;
|
this.settings.values[timer] = value;
|
||||||
this.updateSlider(track.parentNode, values);
|
this.updateSlider(track.parentNode);
|
||||||
};
|
};
|
||||||
document.addEventListener("mouseup", mouseUp);
|
document.addEventListener("mouseup", mouseUp);
|
||||||
document.addEventListener("mousemove", mouseMove);
|
document.addEventListener("mousemove", mouseMove);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSlider (slider, values) {
|
updateSlider (slider) {
|
||||||
let bar = slider.querySelector(BDFDB.dotCN.sliderbar);
|
let bar = slider.querySelector(BDFDB.dotCN.sliderbar);
|
||||||
let fill = slider.querySelector(BDFDB.dotCN.sliderbarfill);
|
let fill = slider.querySelector(BDFDB.dotCN.sliderbarfill);
|
||||||
let inverted = values.timer1 > values.timer2;
|
let inverted = this.settings.values.timer1 > this.settings.values.timer2;
|
||||||
fill.style.setProperty("width", (inverted ? (values.timer1 - values.timer2) : (values.timer2 - values.timer1)) + "%");
|
fill.style.setProperty("width", (inverted ? (this.settings.values.timer1 - this.settings.values.timer2) : (this.settings.values.timer2 - this.settings.values.timer1)) + "%");
|
||||||
fill.style.setProperty("margin-left", (inverted ? values.timer2 : values.timer1) + "%");
|
fill.style.setProperty("margin-left", (inverted ? this.settings.values.timer2 : this.settings.values.timer1) + "%");
|
||||||
fill.style.setProperty("background-color", inverted ? "#66757F" : "#E0C460", "important");
|
fill.style.setProperty("background-color", inverted ? "#66757F" : "#E0C460", "important");
|
||||||
bar.style.setProperty("background-color", inverted ? "#E0C460" : "#66757F", "important");
|
bar.style.setProperty("background-color", inverted ? "#E0C460" : "#66757F", "important");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue