stuff
This commit is contained in:
parent
b2d0b3a8a9
commit
3668d821c2
|
@ -86,7 +86,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
else {
|
||||
var translateinterval = BDFDB.TimeUtils.interval(_ => {
|
||||
if (document.querySelector("html").lang) {
|
||||
clearInterval(translateinterval);
|
||||
BDFDB.TimeUtils.clear(translateinterval);
|
||||
translate();
|
||||
}
|
||||
}, 100);
|
||||
|
@ -235,11 +235,9 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
};
|
||||
InternalBDFDB.clearStartTimeout = function (plugin) {
|
||||
if (!BDFDB.ObjectUtils.is(plugin)) return;
|
||||
clearTimeout(plugin.startTimeout);
|
||||
BDFDB.TimeUtils.clear(plugin.startTimeout, plugin.libLoadTimeout, BDFDB.cleanUps[plugin.name]);
|
||||
delete plugin.startTimeout;
|
||||
clearTimeout(plugin.libLoadTimeout);
|
||||
delete plugin.libLoadTimeout;
|
||||
clearImmediate(BDFDB.cleanUps[plugin.name]);
|
||||
delete BDFDB.cleanUps[plugin.name];
|
||||
};
|
||||
InternalBDFDB.addOnSettingsClosedListener = function (plugin) {
|
||||
|
@ -477,7 +475,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
var audio = new Audio();
|
||||
var timeout = BDFDB.TimeUtils.timeout(_ => {close();}, options.timeout ? options.timeout : 3000);
|
||||
if (typeof options.click == "function") notification.onclick = _ => {
|
||||
clearTimeout(timeout);
|
||||
BDFDB.TimeUtils.clear(timeout);
|
||||
close();
|
||||
options.click();
|
||||
};
|
||||
|
@ -2921,7 +2919,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
var newv = parseInt(input.value) + 1;
|
||||
if (isNaN(max) || !isNaN(max) && newv <= max) {
|
||||
BDFDB.DOMUtils.addClass(ele.parentElement, "pressed");
|
||||
clearTimeout(ele.parentElement.pressedTimeout);
|
||||
BDFDB.TimeUtils.clear(ele.parentElement.pressedTimeout);
|
||||
input.value = isNaN(min) || !isNaN(min) && newv >= min ? newv : min;
|
||||
input.dispatchEvent(new Event("change"));
|
||||
input.dispatchEvent(new Event("input"));
|
||||
|
@ -2940,7 +2938,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
var newv = parseInt(input.value) - 1;
|
||||
if (isNaN(min) || !isNaN(min) && newv >= min) {
|
||||
BDFDB.DOMUtils.addClass(ele.parentElement, "pressed");
|
||||
clearTimeout(ele.parentElement.pressedTimeout);
|
||||
BDFDB.TimeUtils.clear(ele.parentElement.pressedTimeout);
|
||||
input.value = isNaN(max) || !isNaN(max) && newv <= max ? newv : max;
|
||||
input.dispatchEvent(new Event("change"));
|
||||
input.dispatchEvent(new Event("input"));
|
||||
|
@ -3620,10 +3618,14 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
else if (typeof delay != "number" || delay < 1) return setImmediate(() => {BDFDB.TimeUtils.suppress(callback, "Immediate")();});
|
||||
else return setTimeout(() => {BDFDB.TimeUtils.suppress(callback, "Timeout")();}, delay);
|
||||
};
|
||||
BDFDB.TimeUtils.clear = function (timeobject) {
|
||||
clearInterval(timeobject);
|
||||
clearTimeout(timeobject);
|
||||
clearImmediate(timeobject);
|
||||
BDFDB.TimeUtils.clear = function (...timeobjects) {
|
||||
for (let t of timeobjects.flat()) {
|
||||
if (typeof t == "number") {
|
||||
clearInterval(t);
|
||||
clearTimeout(t);
|
||||
}
|
||||
else if (typeof t == "object") clearImmediate(t);
|
||||
}
|
||||
};
|
||||
BDFDB.TimeUtils.suppress = function (callback, string, name) {return function (...args) {
|
||||
try {return callback(...args);}
|
||||
|
@ -5600,7 +5602,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
}
|
||||
updateCounter() {
|
||||
if (!this.refElement) return;
|
||||
clearTimeout(this.updateTimeout);
|
||||
BDFDB.TimeUtils.clear(this.updateTimeout);
|
||||
this.updateTimeout = BDFDB.TimeUtils.timeout(this.forceUpdateCounter.bind(this), 100);
|
||||
}
|
||||
forceUpdateCounter() {
|
||||
|
@ -6174,7 +6176,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
if (typeof this.props.onMouseLeave == "function") this.props.onMouseLeave(e, this);
|
||||
}
|
||||
handleNumberButton(ins, value) {
|
||||
clearTimeout(ins.pressedTimeout);
|
||||
BDFDB.TimeUtils.clear(ins.pressedTimeout);
|
||||
ins.pressedTimeout = BDFDB.TimeUtils.timeout(_ => {
|
||||
delete this.props.focused;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
|
@ -6683,7 +6685,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
};
|
||||
var initDiscordLanguageInterval = (_ => {
|
||||
if (document.querySelector("html").lang) {
|
||||
clearInterval(initDiscordLanguageInterval);
|
||||
BDFDB.TimeUtils.clear(initDiscordLanguageInterval);
|
||||
var language = BDFDB.LanguageUtils.getLanguage();
|
||||
BDFDB.LanguageUtils.languages.$discord.name = `Discord (${language.name})`;
|
||||
BDFDB.LanguageUtils.languages.$discord.id = language.id;
|
||||
|
@ -7588,13 +7590,13 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
var KeyDownTimeouts = {};
|
||||
BDFDB.ListenerUtils.add(BDFDB, document, "keydown.BDFDBPressedKeys", e => {
|
||||
if (!BDFDB.pressedKeys.includes(e.which)) {
|
||||
clearTimeout(KeyDownTimeouts[e.which]);
|
||||
BDFDB.TimeUtils.clear(KeyDownTimeouts[e.which]);
|
||||
BDFDB.pressedKeys.push(e.which);
|
||||
KeyDownTimeouts[e.which] = BDFDB.TimeUtils.timeout(_ => {BDFDB.ArrayUtils.remove(BDFDB.pressedKeys, e.which, true);},60000);
|
||||
}
|
||||
});
|
||||
BDFDB.ListenerUtils.add(BDFDB, document, "keyup.BDFDBPressedKeys", e => {
|
||||
clearTimeout(KeyDownTimeouts[e.which]);
|
||||
BDFDB.TimeUtils.clear(KeyDownTimeouts[e.which]);
|
||||
BDFDB.ArrayUtils.remove(BDFDB.pressedKeys, e.which, true);
|
||||
});
|
||||
BDFDB.ListenerUtils.add(BDFDB, document, "mousedown.BDFDBMousePosition", e => {
|
||||
|
@ -7750,14 +7752,14 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
var libKeys = Object.keys(BDFDB).length - 10, crashInterval = BDFDB.TimeUtils.interval(_ => {
|
||||
if (!window.BDFDB || typeof BDFDB != "object" || Object.keys(BDFDB).length < libKeys || !BDFDB.id) {
|
||||
console.warn(`%c[BDFDB]%c`, "color: #3a71c1; font-weight: 700;", "", "reloading library due to internal error.");
|
||||
clearInterval(crashInterval);
|
||||
BDFDB.TimeUtils.clear(crashInterval);
|
||||
InternalBDFDB.reloadLib();
|
||||
}
|
||||
else if (BDFDB.id != id) {
|
||||
clearInterval(crashInterval);
|
||||
BDFDB.TimeUtils.clear(crashInterval);
|
||||
}
|
||||
else if (!BDFDB.creationTime || performance.now() - BDFDB.creationTime > 18000000) {
|
||||
clearInterval(crashInterval);
|
||||
BDFDB.TimeUtils.clear(crashInterval);
|
||||
InternalBDFDB.reloadLib();
|
||||
}
|
||||
}, 10000);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -114,8 +114,8 @@ class BetterFriendCount {
|
|||
}
|
||||
|
||||
processFriendRow () {
|
||||
clearTimeout(this.rerenderTimeout);
|
||||
this.rerenderTimeout = setTimeout(() => {
|
||||
BDFDB.TimeUtils.clear(this.rerenderTimeout);
|
||||
this.rerenderTimeout = BDFDB.TimeUtils.timeout(() => {
|
||||
delete this.rerenderTimeout;
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this, "TabBar");
|
||||
}, 1000);
|
||||
|
|
|
@ -165,24 +165,24 @@ class CharCounter {
|
|||
BDFDB.DOMUtils.addClass(input.parentElement.parentElement, "charcounter-added");
|
||||
if (type == "nickname") input.setAttribute("maxlength", 32);
|
||||
BDFDB.ListenerUtils.add(this, input, "keydown click change", e => {
|
||||
clearTimeout(input.charcountertimeout);
|
||||
input.charcountertimeout = setTimeout(() => {updateCounter();},100);
|
||||
BDFDB.TimeUtils.clear(input.charcountertimeout);
|
||||
input.charcountertimeout = BDFDB.TimeUtils.timeout(() => {updateCounter();},100);
|
||||
});
|
||||
BDFDB.ListenerUtils.add(this, input, "mousedown", e => {
|
||||
BDFDB.ListenerUtils.add(this, document, "mouseup", () => {
|
||||
BDFDB.ListenerUtils.remove(this, document);
|
||||
if (this.props.end - input.selectionStart) setImmediate(() => {BDFDB.ListenerUtils.add(this, document, "click", () => {
|
||||
if (this.props.end - input.selectionStart) BDFDB.TimeUtils.timeout(() => {BDFDB.ListenerUtils.add(this, document, "click", () => {
|
||||
var contexttype = BDFDB.ReactUtils.getValue(document.querySelector(BDFDB.dotCN.contextmenu), "return.stateNode.props.type");
|
||||
if (!contexttype || !contexttype.startsWith("CHANNEL_TEXT_AREA")) {
|
||||
input.selectionStart = 0;
|
||||
this.props.end = 0;
|
||||
updateCounter();
|
||||
}
|
||||
else setTimeout(() => {updateCounter();},100);
|
||||
else BDFDB.TimeUtils.timeout(() => {updateCounter();},100);
|
||||
BDFDB.ListenerUtils.remove(this, document);
|
||||
});});
|
||||
});
|
||||
BDFDB.ListenerUtils.add(this, document, "mousemove", () => {setTimeout(() => {updateCounter();},10);});
|
||||
BDFDB.ListenerUtils.add(this, document, "mousemove", () => {BDFDB.TimeUtils.timeout(() => {updateCounter();},10);});
|
||||
});
|
||||
|
||||
updateCounter();
|
||||
|
|
|
@ -253,8 +253,8 @@ class ChatAliases {
|
|||
}
|
||||
|
||||
updateWord (ele) {
|
||||
clearTimeout(ele.updateTimeout);
|
||||
ele.updateTimeout = setTimeout(() => {
|
||||
BDFDB.TimeUtils.clear(ele.updateTimeout);
|
||||
ele.updateTimeout = BDFDB.TimeUtils.timeout(() => {
|
||||
var card = ele.parentElement.parentElement;
|
||||
var oldwordvalue = ele.getAttribute("word");
|
||||
if (oldwordvalue && this.aliases[oldwordvalue]) {
|
||||
|
@ -378,14 +378,14 @@ class ChatAliases {
|
|||
textarea.dispatchEvent(new Event("input"));
|
||||
}
|
||||
else if (!e.ctrlKey && e.which != 16 && settings.addAutoComplete && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) {
|
||||
clearTimeout(textarea.ChatAliasAutocompleteTimeout);
|
||||
textarea.ChatAliasAutocompleteTimeout = setTimeout(() => {this.addAutoCompleteMenu(textarea);},100);
|
||||
BDFDB.TimeUtils.clear(textarea.ChatAliasAutocompleteTimeout);
|
||||
textarea.ChatAliasAutocompleteTimeout = BDFDB.TimeUtils.timeout(() => {this.addAutoCompleteMenu(textarea);},100);
|
||||
}
|
||||
|
||||
if (!e.ctrlKey && e.which != 38 && e.which != 40 && !(e.which == 39 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length)) BDFDB.DOMUtils.remove(".autocompleteAliases", ".autocompleteAliasesRow");
|
||||
});
|
||||
BDFDB.ListenerUtils.add(this, textarea, "click", e => {
|
||||
if (settings.addAutoComplete && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) setImmediate(() => {this.addAutoCompleteMenu(textarea);});
|
||||
if (settings.addAutoComplete && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) BDFDB.TimeUtils.timeout(() => {this.addAutoCompleteMenu(textarea);});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -580,6 +580,6 @@ class ChatAliases {
|
|||
});
|
||||
wordvalueinput.focus();
|
||||
|
||||
setTimeout(checkInputs, 500);
|
||||
BDFDB.TimeUtils.timeout(checkInputs, 500);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ class CompleteTimestamps {
|
|||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".settings-switch", () => {setImmediate(() => {this.updateSettingsPanel(settingspanel);})});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".settings-switch", () => {BDFDB.TimeUtils.timeout(() => {this.updateSettingsPanel(settingspanel);})});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {
|
||||
|
|
|
@ -88,7 +88,7 @@ class CreationDate {
|
|||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".settings-switch", () => {setImmediate(() => {this.updateSettingsPanel(settingspanel);})});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".settings-switch", () => {BDFDB.TimeUtils.timeout(() => {this.updateSettingsPanel(settingspanel);})});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {
|
||||
|
|
|
@ -289,14 +289,14 @@ class EditChannels {
|
|||
textarea.dispatchEvent(new Event("input"));
|
||||
}
|
||||
else if (!e.ctrlKey && e.which != 16 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) {
|
||||
clearTimeout(textarea.EditChannelsAutocompleteTimeout);
|
||||
textarea.EditChannelsAutocompleteTimeout = setTimeout(() => {this.addAutoCompleteMenu(textarea, channel);},100);
|
||||
BDFDB.TimeUtils.clear(textarea.EditChannelsAutocompleteTimeout);
|
||||
textarea.EditChannelsAutocompleteTimeout = BDFDB.TimeUtils.timeout(() => {this.addAutoCompleteMenu(textarea, channel);},100);
|
||||
}
|
||||
|
||||
if (!e.ctrlKey && e.which != 38 && e.which != 40 && !(e.which == 39 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length)) BDFDB.DOMUtils.remove(".autocompleteEditChannels", ".autocompleteEditChannelsRow");
|
||||
});
|
||||
BDFDB.ListenerUtils.add(this, textarea, "click", e => {
|
||||
if (textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) setImmediate(() => {this.addAutoCompleteMenu(textarea, channel);});
|
||||
if (textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) BDFDB.TimeUtils.timeout(() => {this.addAutoCompleteMenu(textarea, channel);});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -413,13 +413,13 @@ class EditServers {
|
|||
|
||||
checkUrl (url, instance) {
|
||||
let input = BDFDB.ReactUtils.findDOMNode(instance).firstElementChild;
|
||||
clearTimeout(instance.checkTimeout);
|
||||
BDFDB.TimeUtils.clear(instance.checkTimeout);
|
||||
if (url == null || !url.trim()) {
|
||||
if (input) BDFDB.DOMUtils.remove(input.tooltip);
|
||||
instance.props.inputClassName = null;
|
||||
instance.forceUpdate();
|
||||
}
|
||||
else instance.checkTimeout = setTimeout(() => {
|
||||
else instance.checkTimeout = BDFDB.TimeUtils.timeout(() => {
|
||||
BDFDB.LibraryRequires.request(url.trim(), (error, response, result) => {
|
||||
if (response && response.headers["content-type"] && response.headers["content-type"].indexOf("image") != -1) {
|
||||
if (input) BDFDB.DOMUtils.remove(input.tooltip);
|
||||
|
|
|
@ -434,14 +434,14 @@ class EditUsers {
|
|||
textarea.dispatchEvent(new Event("input"));
|
||||
}
|
||||
else if (!e.ctrlKey && e.which != 16 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) {
|
||||
clearTimeout(textarea.EditUsersAutocompleteTimeout);
|
||||
textarea.EditUsersAutocompleteTimeout = setTimeout(() => {this.addAutoCompleteMenu(textarea, channel);},100);
|
||||
BDFDB.TimeUtils.clear(textarea.EditUsersAutocompleteTimeout);
|
||||
textarea.EditUsersAutocompleteTimeout = BDFDB.TimeUtils.timeout(() => {this.addAutoCompleteMenu(textarea, channel);},100);
|
||||
}
|
||||
|
||||
if (!e.ctrlKey && e.which != 38 && e.which != 40 && !(e.which == 39 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length)) BDFDB.DOMUtils.remove(".autocompleteEditUsers", ".autocompleteEditUsersRow");
|
||||
});
|
||||
BDFDB.ListenerUtils.add(this, textarea, "click", e => {
|
||||
if (textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) setImmediate(() => {this.addAutoCompleteMenu(textarea, channel);});
|
||||
if (textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) BDFDB.TimeUtils.timeout(() => {this.addAutoCompleteMenu(textarea, channel);});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -711,13 +711,13 @@ class EditUsers {
|
|||
|
||||
checkUrl (url, instance) {
|
||||
let input = BDFDB.ReactUtils.findDOMNode(instance).firstElementChild;
|
||||
clearTimeout(instance.checkTimeout);
|
||||
BDFDB.TimeUtils.clear(instance.checkTimeout);
|
||||
if (url == null || !url.trim()) {
|
||||
if (input) BDFDB.DOMUtils.remove(input.tooltip);
|
||||
instance.props.inputClassName = null;
|
||||
instance.forceUpdate();
|
||||
}
|
||||
else instance.checkTimeout = setTimeout(() => {
|
||||
else instance.checkTimeout = BDFDB.TimeUtils.timeout(() => {
|
||||
BDFDB.LibraryRequires.request(url.trim(), (error, response, result) => {
|
||||
if (response && response.headers["content-type"] && response.headers["content-type"].indexOf("image") != -1) {
|
||||
if (input) BDFDB.DOMUtils.remove(input.tooltip);
|
||||
|
|
|
@ -332,7 +332,7 @@ class FriendNotifications {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
this.stopping = true;
|
||||
|
||||
clearInterval(this.checkInterval);
|
||||
BDFDB.TimeUtils.clear(this.checkInterval);
|
||||
BDFDB.PluginUtils.clear(this);
|
||||
}
|
||||
}
|
||||
|
@ -480,7 +480,7 @@ class FriendNotifications {
|
|||
}
|
||||
|
||||
startInterval () {
|
||||
clearInterval(this.checkInterval);
|
||||
BDFDB.TimeUtils.clear(this.checkInterval);
|
||||
let settings = BDFDB.DataUtils.get(this, "settings");
|
||||
let amounts = BDFDB.DataUtils.get(this, "amounts");
|
||||
let notificationstrings = BDFDB.DataUtils.get(this, "notificationstrings");
|
||||
|
@ -489,7 +489,7 @@ class FriendNotifications {
|
|||
for (let id in users) this.userStatusStore[id] = this.getStatusWithMobileAndActivity(id, users[id]).statusname;
|
||||
let toasttime = (amounts.toastTime > amounts.checkInterval ? amounts.checkInterval : amounts.toastTime) * 1000;
|
||||
let desktoptime = (amounts.desktopTime > amounts.checkInterval ? amounts.checkInterval : amounts.desktopTime) * 1000;
|
||||
this.checkInterval = setInterval(() => {
|
||||
this.checkInterval = BDFDB.TimeUtils.interval(() => {
|
||||
for (let id in users) if (!users[id].disabled) {
|
||||
let user = BDFDB.LibraryModules.UserStore.getUser(id);
|
||||
let status = this.getStatusWithMobileAndActivity(id, users[id]);
|
||||
|
|
|
@ -498,7 +498,7 @@ class GoogleTranslateOption {
|
|||
var finishTranslation = (translation, exceptions, input, output, toast) => {
|
||||
if (translation) translation = this.addExceptions(translation, exceptions);
|
||||
if (toast) {
|
||||
clearInterval(toast.interval);
|
||||
BDFDB.TimeUtils.clear(toast.interval);
|
||||
toast.close();
|
||||
}
|
||||
callback(translation, input, output);
|
||||
|
@ -513,7 +513,7 @@ class GoogleTranslateOption {
|
|||
var translation = "";
|
||||
if (translate) {
|
||||
toast = BDFDB.NotificationUtils.toast("Translating. Please wait", {timeout:0});
|
||||
toast.interval = setInterval(() => {
|
||||
toast.interval = BDFDB.TimeUtils.interval(() => {
|
||||
toast.textContent = toast.textContent.indexOf(".....") > -1 ? "Translating. Please wait" : toast.textContent + ".";
|
||||
},500);
|
||||
var specialcase = this.checkForSpecialCase(newtext, input);
|
||||
|
|
|
@ -99,10 +99,10 @@ class ImageGallery {
|
|||
let modal = BDFDB.DOMUtils.getParent(BDFDB.dotCN.modal, wrapper);
|
||||
if (!modal) return;
|
||||
let start = performance.now();
|
||||
let waitForImg = setInterval(() => {
|
||||
let waitForImg = BDFDB.TimeUtils.interval(() => {
|
||||
let img = modal.querySelector(BDFDB.dotCNS.imagewrapper + "img");
|
||||
if (img && img.src) {
|
||||
clearInterval(waitForImg);
|
||||
BDFDB.TimeUtils.clear(waitForImg);
|
||||
let message = this.getMessageGroupOfImage(img);
|
||||
if (message) {
|
||||
BDFDB.DOMUtils.addClass(modal, "image-gallery");
|
||||
|
@ -110,7 +110,7 @@ class ImageGallery {
|
|||
}
|
||||
}
|
||||
else if (performance.now() - start > 10000) {
|
||||
clearInterval(waitForImg);
|
||||
BDFDB.TimeUtils.clear(waitForImg);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
|
|
@ -102,10 +102,10 @@ class ImageZoom {
|
|||
let inner = modal.querySelector(BDFDB.dotCN.modalinner);
|
||||
if (!inner) return;
|
||||
let start = performance.now();
|
||||
let waitForImg = setInterval(() => {
|
||||
let waitForImg = BDFDB.TimeUtils.interval(() => {
|
||||
let img = modal.querySelector(BDFDB.dotCNS.imagewrapper + "img," + BDFDB.dotCNS.imagewrapper + "video");
|
||||
if (img && img.src && !BDFDB.DOMUtils.containsClass(img, BDFDB.disCN.imageplaceholder)) {
|
||||
clearInterval(waitForImg);
|
||||
BDFDB.TimeUtils.clear(waitForImg);
|
||||
img.setAttribute("draggable", "false");
|
||||
inner.firstElementChild.appendChild(BDFDB.DOMUtils.create(`<span class="${BDFDB.disCN.downloadlink} imagezoom-separator" style="margin: 0px 5px;"> | </div>`));
|
||||
let settingslink = BDFDB.DOMUtils.create(`<span class="${BDFDB.disCN.downloadlink} imagezoom-settings">Zoom ${BDFDB.LanguageUtils.LanguageStrings.SETTINGS}</div>`);
|
||||
|
@ -122,7 +122,7 @@ class ImageZoom {
|
|||
BDFDB.DataUtils.save(Math.round(BDFDB.NumberUtils.mapRange([0, 100], [this.defaults.settings[type].min, this.defaults.settings[type].max], value)), this, "settings", type);
|
||||
},
|
||||
onValueRender: value => {
|
||||
setImmediate(() => {for (let slider of document.querySelectorAll(BDFDB.dotCN.contextmenuitemslider)) if (BDFDB.ReactUtils.getValue(slider, "return.memoizedProps.type") == type) {
|
||||
BDFDB.TimeUtils.timeout(() => {for (let slider of document.querySelectorAll(BDFDB.dotCN.contextmenuitemslider)) if (BDFDB.ReactUtils.getValue(slider, "return.memoizedProps.type") == type) {
|
||||
value = Math.round(BDFDB.NumberUtils.mapRange([0, 100], [this.defaults.settings[type].min, this.defaults.settings[type].max], value));
|
||||
let label = slider.querySelector(BDFDB.dotCN.contextmenulabel);
|
||||
if (label) label.innerText = this.defaults.settings[type].name + ": " + value + this.defaults.settings[type].unit;
|
||||
|
@ -182,7 +182,7 @@ class ImageZoom {
|
|||
img.addEventListener("mousedown", img.ImageZoomMouseDownListener);
|
||||
}
|
||||
else if (performance.now() - start > 10000) {
|
||||
clearInterval(waitForImg);
|
||||
BDFDB.TimeUtils.clear(waitForImg);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ class JoinedAtDate {
|
|||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".settings-switch", () => {setImmediate(() => {this.updateSettingsPanel(settingspanel);})});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".settings-switch", () => {BDFDB.TimeUtils.timeout(() => {this.updateSettingsPanel(settingspanel);})});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {
|
||||
|
|
|
@ -90,7 +90,7 @@ class LastMessageDate {
|
|||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".settings-switch", () => {setImmediate(() => {this.updateSettingsPanel(settingspanel);})});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".settings-switch", () => {BDFDB.TimeUtils.timeout(() => {this.updateSettingsPanel(settingspanel);})});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {
|
||||
|
|
|
@ -238,7 +238,7 @@ class MessageUtilities {
|
|||
let binding = BDFDB.DataUtils.get(this, "bindings", action);
|
||||
binding[option] = parseInt(recorderWrap.getAttribute("value"));
|
||||
BDFDB.DataUtils.save(binding, this, "bindings", action);
|
||||
setTimeout(() => {
|
||||
BDFDB.TimeUtils.timeout(() => {
|
||||
BDFDB.DOMUtils.removeClass(recorderWrap, BDFDB.disCN.hotkeyrecording);
|
||||
BDFDB.DOMUtils.addClass(recorderWrap, BDFDB.disCN.hotkeyhasvalue);
|
||||
recorderText.innerText = BDFDB.LanguageUtils.LanguageStrings.SHORTCUT_RECORDER_BUTTON_EDIT;
|
||||
|
@ -277,11 +277,11 @@ class MessageUtilities {
|
|||
let {messagediv, pos, message} = this.getMessageData(e.currentTarget);
|
||||
if (messagediv && pos > -1 && message) {
|
||||
BDFDB.ListenerUtils.stopEvent(e);
|
||||
clearTimeout(this.clickTimeout);
|
||||
BDFDB.TimeUtils.clear(this.clickTimeout);
|
||||
if (!this.hasDoubleClickOverwrite(bindings, bindings[priorityaction])) {
|
||||
this.defaults.bindings[priorityaction].func.bind(this)({messagediv, pos, message}, priorityaction);
|
||||
}
|
||||
else this.clickTimeout = setTimeout(() => {
|
||||
else this.clickTimeout = BDFDB.TimeUtils.timeout(() => {
|
||||
this.defaults.bindings[priorityaction].func.bind(this)({messagediv, pos, message}, priorityaction);
|
||||
}, 500);
|
||||
}
|
||||
|
@ -442,6 +442,6 @@ class MessageUtilities {
|
|||
}
|
||||
|
||||
cancelEvent (name) {
|
||||
setImmediate(() => {BDFDB.ArrayUtils.remove(this.firedEvents, name)});
|
||||
BDFDB.TimeUtils.timeout(() => {BDFDB.ArrayUtils.remove(this.firedEvents, name)});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class MoveablePopups {
|
|||
libraryScript.setAttribute("date", performance.now());
|
||||
libraryScript.addEventListener("load", () => {this.initialize();});
|
||||
document.head.appendChild(libraryScript);
|
||||
this.libLoadTimeout = setTimeout(() => {
|
||||
this.libLoadTimeout = BDFDB.TimeUtils.timeout(() => {
|
||||
libraryScript.remove();
|
||||
require("request")("https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js", (error, response, body) => {
|
||||
if (body) {
|
||||
|
@ -120,7 +120,7 @@ class MoveablePopups {
|
|||
BDFDB.DOMUtils.removeLocalStyle("disableTextSelection");
|
||||
document.removeEventListener("mouseup", mouseup);
|
||||
document.removeEventListener("mousemove", mousemove);
|
||||
setTimeout(() => {this.dragging = false},1);
|
||||
BDFDB.TimeUtils.timeout(() => {this.dragging = false},1);
|
||||
};
|
||||
var mousemove = e2 => {
|
||||
left = left - (oldX - e2.pageX);
|
||||
|
|
|
@ -241,7 +241,7 @@ class NotificationSounds {
|
|||
|
||||
BDFDB.ModuleUtils.patch(this, BDFDB.LibraryModules.SoundUtils, "playSound", {instead: e => {
|
||||
let type = e.methodArguments[0];
|
||||
if (this.choices[type]) setImmediate(() => {
|
||||
if (this.choices[type]) BDFDB.TimeUtils.timeout(() => {
|
||||
if (type == "message1") {
|
||||
if (this.firedEvents["dm"]) this.firedEvents["dm"] = false;
|
||||
else if (this.firedEvents["mentioned"]) this.firedEvents["mentioned"] = false;
|
||||
|
@ -328,7 +328,7 @@ class NotificationSounds {
|
|||
if (e2.target.parentElement != selectMenu) {
|
||||
document.removeEventListener("mousedown", removeMenu);
|
||||
selectMenu.remove();
|
||||
setTimeout(() => {BDFDB.DOMUtils.removeClass(selectWrap, BDFDB.disCN.selectisopen);},100);
|
||||
BDFDB.TimeUtils.timeout(() => {BDFDB.DOMUtils.removeClass(selectWrap, BDFDB.disCN.selectisopen);},100);
|
||||
}
|
||||
};
|
||||
document.addEventListener("mousedown", removeMenu);
|
||||
|
@ -498,7 +498,7 @@ class NotificationSounds {
|
|||
|
||||
fireEvent (type) {
|
||||
this.firedEvents[type] = true;
|
||||
setTimeout(() => {this.firedEvents[type] = false;},3000);
|
||||
BDFDB.TimeUtils.timeout(() => {this.firedEvents[type] = false;},3000);
|
||||
}
|
||||
|
||||
processIncomingCalls (instance, wrapper, returnvalue) {
|
||||
|
|
|
@ -324,12 +324,12 @@ class PersonalPins {
|
|||
this.addNotes(notespopout);
|
||||
});});
|
||||
notespopout.querySelector(BDFDB.dotCN.searchbarinput).addEventListener("keyup", () => {
|
||||
clearTimeout(notespopout.searchTimeout);
|
||||
notespopout.searchTimeout = setTimeout(() => {this.addNotes(notespopout);},1000);
|
||||
BDFDB.TimeUtils.clear(notespopout.searchTimeout);
|
||||
notespopout.searchTimeout = BDFDB.TimeUtils.timeout(() => {this.addNotes(notespopout);},1000);
|
||||
});
|
||||
notespopout.querySelector(BDFDB.dotCN.searchbarclear).addEventListener("click", e => {
|
||||
clearTimeout(notespopout.searchTimeout);
|
||||
notespopout.searchTimeout = setTimeout(() => {this.addNotes(notespopout);},1000);
|
||||
BDFDB.TimeUtils.clear(notespopout.searchTimeout);
|
||||
notespopout.searchTimeout = BDFDB.TimeUtils.timeout(() => {this.addNotes(notespopout);},1000);
|
||||
});
|
||||
notespopout.querySelector(BDFDB.dotCN.recentmentionsmentionfilter).addEventListener("click", e => {
|
||||
BDFDB.createSortPopout(e.currentTarget, this.sortPopoutMarkup, () => {this.addNotes(notespopout);});
|
||||
|
@ -339,7 +339,7 @@ class PersonalPins {
|
|||
if (!notespopout.contains(e.target) && !BDFDB.DOMUtils.getParent(".personalpins-sort-popout", e.target)) {
|
||||
document.removeEventListener("mousedown", removePopout);
|
||||
notespopout.remove();
|
||||
setTimeout(() => {BDFDB.DOMUtils.removeClass(button, BDFDB.disCN.channelheadericonselected);},300);
|
||||
BDFDB.TimeUtils.timeout(() => {BDFDB.DOMUtils.removeClass(button, BDFDB.disCN.channelheadericonselected);},300);
|
||||
}
|
||||
};
|
||||
document.addEventListener("mousedown", removePopout);
|
||||
|
|
|
@ -291,7 +291,7 @@ class PinDMs {
|
|||
let dmsscroller = document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller);
|
||||
if (dmsscroller) {
|
||||
this.oldScrollerPos = dmsscroller.scrollTop;
|
||||
setTimeout(() => {this.oldScrollerPos = null;},1000);
|
||||
BDFDB.TimeUtils.timeout(() => {this.oldScrollerPos = null;},1000);
|
||||
}
|
||||
});
|
||||
wrapper.querySelector(BDFDB.dotCN.dmchannelclose).addEventListener("click", e => {
|
||||
|
@ -481,8 +481,8 @@ class PinDMs {
|
|||
if (stateNode) {
|
||||
this.updatingScroller = true;
|
||||
BDFDB.ReactUtils.forceUpdate(stateNode);
|
||||
setTimeout(() => {BDFDB.ReactUtils.forceUpdate(stateNode);},500);
|
||||
setTimeout(() => {delete this.updatingScroller;},1000);
|
||||
BDFDB.TimeUtils.timeout(() => {BDFDB.ReactUtils.forceUpdate(stateNode);},500);
|
||||
BDFDB.TimeUtils.timeout(() => {delete this.updatingScroller;},1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -612,7 +612,7 @@ class PinDMs {
|
|||
}
|
||||
|
||||
updatePinnedPositions (type) {
|
||||
setImmediate(() => {
|
||||
BDFDB.TimeUtils.timeout(() => {
|
||||
let newPinned = {}, oldPinned = BDFDB.DataUtils.load(this, type);
|
||||
let pins = Array.from(document.querySelectorAll(type == "pinnedRecents" ? `.pinned-dm` : `${BDFDB.dotCNS.dmchannels + BDFDB.dotCN.dmchannel}.pinned`)).map(div => {return div.getAttribute("channelid");}).reverse();
|
||||
for (let i in pins) if (pins[i]) newPinned[pins[i]] = parseInt(i);
|
||||
|
|
|
@ -306,7 +306,7 @@ class PluginRepo {
|
|||
|
||||
this.loadPlugins();
|
||||
|
||||
this.updateInterval = setInterval(() => {this.checkForNewPlugins();},1000*60*30);
|
||||
this.updateInterval = BDFDB.TimeUtils.interval(() => {this.checkForNewPlugins();},1000*60*30);
|
||||
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
}
|
||||
|
@ -318,8 +318,8 @@ class PluginRepo {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
this.stopping = true;
|
||||
|
||||
clearInterval(this.updateInterval);
|
||||
clearTimeout(this.loading.timeout);
|
||||
BDFDB.TimeUtils.clear(this.updateInterval);
|
||||
BDFDB.TimeUtils.clear(this.loading.timeout);
|
||||
|
||||
BDFDB.DOMUtils.remove(".pluginrepo-notice",".bd-pluginrepobutton",".pluginrepo-loadingicon",BDFDB.dotCN.app + " > .repo-loadingwrapper:empty");
|
||||
|
||||
|
@ -337,7 +337,7 @@ class PluginRepo {
|
|||
// begin of own functions
|
||||
|
||||
onUserSettingsCogContextMenu (instance, menu, returnvalue) {
|
||||
setImmediate(() => {for (let child of returnvalue.props.children) if (child && child.props && child.props.label == "BandagedBD" && Array.isArray(child.props.render)) {
|
||||
BDFDB.TimeUtils.timeout(() => {for (let child of returnvalue.props.children) if (child && child.props && child.props.label == "BandagedBD" && Array.isArray(child.props.render)) {
|
||||
const repoItem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
||||
label: "Plugin Repo",
|
||||
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-repo-contextMenuItem`,
|
||||
|
@ -428,12 +428,12 @@ class PluginRepo {
|
|||
}
|
||||
|
||||
BDFDB.ListenerUtils.addToChildren(pluginRepoModal, "keyup", BDFDB.dotCN.searchbarinput, () => {
|
||||
clearTimeout(pluginRepoModal.searchTimeout);
|
||||
pluginRepoModal.searchTimeout = setTimeout(() => {this.sortEntries(pluginRepoModal);},1000);
|
||||
BDFDB.TimeUtils.clear(pluginRepoModal.searchTimeout);
|
||||
pluginRepoModal.searchTimeout = BDFDB.TimeUtils.timeout(() => {this.sortEntries(pluginRepoModal);},1000);
|
||||
});
|
||||
BDFDB.ListenerUtils.addToChildren(pluginRepoModal, "click", BDFDB.dotCN.searchbarclear, () => {
|
||||
clearTimeout(pluginRepoModal.searchTimeout);
|
||||
pluginRepoModal.searchTimeout = setTimeout(() => {this.sortEntries(pluginRepoModal);},1000);
|
||||
BDFDB.TimeUtils.clear(pluginRepoModal.searchTimeout);
|
||||
pluginRepoModal.searchTimeout = BDFDB.TimeUtils.timeout(() => {this.sortEntries(pluginRepoModal);},1000);
|
||||
});
|
||||
BDFDB.ListenerUtils.addToChildren(pluginRepoModal, "change", ".hide-checkbox", e => {
|
||||
pluginRepoModal.updateHidden = true;
|
||||
|
@ -535,7 +535,7 @@ class PluginRepo {
|
|||
entry.querySelector(".btn-download").addEventListener("click", e => {
|
||||
setEntryState(0);
|
||||
this.downloadPlugin(data);
|
||||
if (pluginRepoModal.querySelector("#input-rnmstart").checked) setTimeout(() => {this.startPlugin(data);},3000);
|
||||
if (pluginRepoModal.querySelector("#input-rnmstart").checked) BDFDB.TimeUtils.timeout(() => {this.startPlugin(data);},3000);
|
||||
});
|
||||
|
||||
container.appendChild(entry);
|
||||
|
@ -603,10 +603,10 @@ class PluginRepo {
|
|||
this.loadedPlugins = {};
|
||||
this.grabbedPlugins = result.split("\n").filter(n => n);
|
||||
this.foundPlugins = this.grabbedPlugins.concat(ownlist);
|
||||
this.loading = {is:true, timeout:setTimeout(() => {
|
||||
clearTimeout(this.loading.timeout);
|
||||
this.loading = {is:true, timeout:BDFDB.TimeUtils.timeout(() => {
|
||||
BDFDB.TimeUtils.clear(this.loading.timeout);
|
||||
if (this.started) {
|
||||
if (this.loading.is && this.loading.amount < 4) setTimeout(() => {this.loadPlugins();},10000);
|
||||
if (this.loading.is && this.loading.amount < 4) BDFDB.TimeUtils.timeout(() => {this.loadPlugins();},10000);
|
||||
this.loading = {is: false, timeout:null, amount:this.loading.amount};
|
||||
}
|
||||
},1200000), amount:this.loading.amount+1};
|
||||
|
@ -625,18 +625,18 @@ class PluginRepo {
|
|||
createFrame().then(() => {
|
||||
getPluginInfo(() => {
|
||||
if (!this.started) {
|
||||
clearTimeout(this.loading.timeout);
|
||||
BDFDB.TimeUtils.clear(this.loading.timeout);
|
||||
BDFDB.DOMUtils.remove(frame);
|
||||
if (frame && frame.messageReceived) window.removeEventListener("message", frame.messageReceived);
|
||||
return;
|
||||
}
|
||||
var finishCounter = 0, finishInterval = setInterval(() => {
|
||||
var finishCounter = 0, finishInterval = BDFDB.TimeUtils.interval(() => {
|
||||
if ((framequeue.length == 0 && !framerunning) || finishCounter > 300 || !this.loading.is) {
|
||||
clearInterval(finishInterval);
|
||||
BDFDB.TimeUtils.clear(finishInterval);
|
||||
BDFDB.DOMUtils.remove(frame, loadingicon, ".pluginrepo-loadingicon");
|
||||
if (frame && frame.messageReceived) window.removeEventListener("message", frame.messageReceived);
|
||||
if (!loadingiconwrapper.firstChild) BDFDB.DOMUtils.remove(loadingiconwrapper);
|
||||
clearTimeout(this.loading.timeout);
|
||||
BDFDB.TimeUtils.clear(this.loading.timeout);
|
||||
this.loading = {is:false, timeout:null, amount:this.loading.amount};
|
||||
console.log(`%c[${this.name}]%c`, "color: #3a71c1; font-weight: 700;", "", "Finished fetching Plugins.");
|
||||
if (document.querySelector(".bd-pluginrepobutton")) BDFDB.NotificationUtils.toast(`Finished fetching Plugins.`, {type:"success"});
|
||||
|
@ -754,7 +754,7 @@ class PluginRepo {
|
|||
var markup = this.frameMarkup;
|
||||
return new Promise(function(callback) {
|
||||
frame = BDFDB.DOMUtils.create(markup);
|
||||
frame.startTimeout = setTimeout(() => {
|
||||
frame.startTimeout = BDFDB.TimeUtils.timeout(() => {
|
||||
callback();
|
||||
},600000);
|
||||
frame.messageReceived = e => {
|
||||
|
|
|
@ -222,7 +222,7 @@ class ReadAllNotificationsButton {
|
|||
for (let btn of wrapper.querySelectorAll(BDFDB.dotCN.messagespopoutclosebutton)) btn.click();
|
||||
if (closebuttons.length) {
|
||||
instance.loadMore();
|
||||
setTimeout(() => {this.clearMentions(instance, wrapper);},3000);
|
||||
BDFDB.TimeUtils.timeout(() => {this.clearMentions(instance, wrapper);},3000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -296,8 +296,8 @@ class RepoControls {
|
|||
orderfilter.innerText = this.sortings.order[sortings.order];
|
||||
|
||||
BDFDB.ListenerUtils.addToChildren(repocontrols, "keyup", BDFDB.dotCN.searchbarinput, () => {
|
||||
clearTimeout(repocontrols.searchTimeout);
|
||||
repocontrols.searchTimeout = setTimeout(() => {this.sortEntries(container, repocontrols);},1000);
|
||||
BDFDB.TimeUtils.clear(repocontrols.searchTimeout);
|
||||
repocontrols.searchTimeout = BDFDB.TimeUtils.timeout(() => {this.sortEntries(container, repocontrols);},1000);
|
||||
});
|
||||
BDFDB.ListenerUtils.addToChildren(repocontrols, "click", BDFDB.dotCN.searchbarclear + BDFDB.dotCN.searchbarvisible, () => {
|
||||
this.sortEntries(container, repocontrols);
|
||||
|
|
|
@ -142,15 +142,15 @@ class SendLargeMessages {
|
|||
}
|
||||
};
|
||||
BDFDB.ListenerUtils.add(this, textarea, "keyup", e => {
|
||||
clearTimeout(textarea.sendlargemessagestimeout);
|
||||
textarea.sendlargemessagestimeout = setTimeout(() => {
|
||||
BDFDB.TimeUtils.clear(textarea.sendlargemessagestimeout);
|
||||
textarea.sendlargemessagestimeout = BDFDB.TimeUtils.timeout(() => {
|
||||
modaltext = textarea.value;
|
||||
checkTextarea();
|
||||
},100);
|
||||
});
|
||||
BDFDB.ListenerUtils.add(this, textarea, "paste", e => {
|
||||
modaltext = textarea.value.slice(0, textarea.selectionStart) + BDFDB.LibraryRequires.electron.clipboard.readText() + textarea.value.slice(textarea.selectionEnd);
|
||||
setImmediate(() => {checkTextarea(textarea);});
|
||||
BDFDB.TimeUtils.timeout(() => {checkTextarea(textarea);});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ class SendLargeMessages {
|
|||
BDFDB.ListenerUtils.addToChildren(sendMessageModal, "click", ".btn-send", e => {
|
||||
let messages = this.formatText(textinput.value || "");
|
||||
messages.forEach((message,i) => {
|
||||
setTimeout(() => {
|
||||
BDFDB.TimeUtils.timeout(() => {
|
||||
this.sendMessage(message);
|
||||
if (i >= messages.length-1) BDFDB.NotificationUtils.toast(this.labels.toast_allsent_text, {type:"success"});
|
||||
},this.messageDelay * i);
|
||||
|
@ -181,7 +181,7 @@ class SendLargeMessages {
|
|||
});
|
||||
|
||||
textinput.value = text || "";
|
||||
textinput.addEventListener("keyup", () => {setTimeout(() => {updateCounter();},10);});
|
||||
textinput.addEventListener("keyup", () => {BDFDB.TimeUtils.timeout(() => {updateCounter();},10);});
|
||||
textinput.addEventListener("click", () => {updateCounter();});
|
||||
textinput.addEventListener("mousedown", () => {
|
||||
var mouseup = () => {
|
||||
|
@ -189,7 +189,7 @@ class SendLargeMessages {
|
|||
document.removeEventListener("mousemove", mousemove);
|
||||
};
|
||||
var mousemove = () => {
|
||||
setTimeout(() => {updateCounter();},10);
|
||||
BDFDB.TimeUtils.timeout(() => {updateCounter();},10);
|
||||
};
|
||||
document.addEventListener("mouseup", mouseup);
|
||||
document.addEventListener("mousemove", mousemove);
|
||||
|
|
|
@ -433,7 +433,7 @@ class ServerFolders {
|
|||
}
|
||||
};
|
||||
if (document.querySelector(BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildouter + ":not(.copy) " + BDFDB.dotCN.guildiconwrapper)) process();
|
||||
else setTimeout(process, 5000);
|
||||
else BDFDB.TimeUtils.timeout(process, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -446,12 +446,12 @@ class ServerFolders {
|
|||
}
|
||||
if (!BDFDB.equals(state, this.folderStates[instance.props.folderId])) {
|
||||
if (data.autoRead && (state.unread || state.badge > 0)) {
|
||||
clearTimeout(this.folderReads[state.folderId]);
|
||||
this.folderReads[state.folderId] = setTimeout(() => {
|
||||
BDFDB.TimeUtils.clear(this.folderReads[state.folderId]);
|
||||
this.folderReads[state.folderId] = BDFDB.TimeUtils.timeout(() => {
|
||||
BDFDB.GuildUtils.markAsRead(instance.props.guildIds);
|
||||
}, 10000);
|
||||
}
|
||||
if (state.expanded) setImmediate(() => {
|
||||
if (state.expanded) BDFDB.TimeUtils.timeout(() => {
|
||||
for (let guildid of instance.props.guildIds) this.updateGuildInFolderContent(state.folderId, guildid);
|
||||
if (this.clickedFolder == state.folderId && BDFDB.DataUtils.get(this, "settings", "closeOtherFolders")) for (let openFolderId of BDFDB.LibraryModules.FolderUtils.getExpandedFolders()) if (openFolderId != state.folderId) {
|
||||
BDFDB.DOMUtils.remove(this.foldercontent.querySelectorAll(`${BDFDB.dotCN.guildouter}[folderid="${openFolderId}"]`));
|
||||
|
@ -460,7 +460,7 @@ class ServerFolders {
|
|||
this.addSeparator(state.folderId);
|
||||
this.toggleFolderContent();
|
||||
});
|
||||
else setTimeout(() => {
|
||||
else BDFDB.TimeUtils.timeout(() => {
|
||||
BDFDB.DOMUtils.remove(this.foldercontent.querySelectorAll(`${BDFDB.dotCN.guildouter}[folderid="${state.folderId}"]`));
|
||||
if (BDFDB.DOMUtils.containsClass(this.foldercontentguilds.firstElementChild, "folderseparatorouter")) BDFDB.DOMUtils.remove(this.foldercontentguilds.firstElementChild);
|
||||
this.toggleFolderContent();
|
||||
|
@ -474,7 +474,7 @@ class ServerFolders {
|
|||
if (!this.foldercontentguilds) return;
|
||||
if (instance.props && instance.props.guild) {
|
||||
if (methodnames.includes("componentDidMount")) {
|
||||
BDFDB.ListenerUtils.add(this, wrapper, "click", () => {setImmediate(() => {
|
||||
BDFDB.ListenerUtils.add(this, wrapper, "click", () => {BDFDB.TimeUtils.timeout(() => {
|
||||
let folder = this.getFolderOfGuildId(instance.props.guild.id);
|
||||
let folderid = folder ? folder.folderId : null;
|
||||
let settings = BDFDB.DataUtils.get(this, "settings");
|
||||
|
@ -509,7 +509,7 @@ class ServerFolders {
|
|||
BDFDB.DOMUtils.addClass(root, "BDFDB-modal", `${this.name}-modal`, BDFDB.disCN.layermodalmedium);
|
||||
BDFDB.DOMUtils.removeClass(root, BDFDB.disCN.layermodalsmall);
|
||||
if (header) {
|
||||
clearInterval(this.settingsModalWait);
|
||||
BDFDB.TimeUtils.clear(this.settingsModalWait);
|
||||
header.parentElement.insertBefore(BDFDB.DOMUtils.create(`<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.marginbottom8 + BDFDB.disCN.tabbarcontainer}" style="flex: 0 0 auto; padding-right: 12px;"><div class="${BDFDB.disCNS.tabbar + BDFDB.disCN.tabbartop}"><div tab="folder" class="${BDFDB.disCNS.settingsitem + BDFDB.disCN.tabbaritem}">${this.labels.modal_tabheader1_text}</div><div tab="icon" class="${BDFDB.disCNS.settingsitem + BDFDB.disCN.tabbaritem}">${this.labels.modal_tabheader2_text}</div><div tab="tooltip" class="${BDFDB.disCNS.settingsitem + BDFDB.disCN.tabbaritem}">${this.labels.modal_tabheader3_text}</div><div tab="custom" class="${BDFDB.disCNS.settingsitem + BDFDB.disCN.tabbaritem}">${this.labels.modal_tabheader4_text}</div></div></div>`), header.nextElementSibling);
|
||||
}
|
||||
if (root && form) {
|
||||
|
@ -535,7 +535,7 @@ class ServerFolders {
|
|||
|
||||
BDFDB.ListenerUtils.addToChildren(root, "change", "input[type='file'][option]", e => {
|
||||
let input = e.currentTarget, file = input.files[0];
|
||||
if (file) setImmediate(() => {this.fetchCustomIcon(root, input.getAttribute("option"))});
|
||||
if (file) BDFDB.TimeUtils.timeout(() => {this.fetchCustomIcon(root, input.getAttribute("option"))});
|
||||
});
|
||||
BDFDB.ListenerUtils.addToChildren(root, "keyup", "input[type='text'][option]", e => {
|
||||
if (e.which == 13) this.fetchCustomIcon(root, e.currentTarget.getAttribute("option"));
|
||||
|
@ -636,7 +636,7 @@ class ServerFolders {
|
|||
BDFDB.DOMUtils.removeClass(iconpreviewswitching, "nopic");
|
||||
iconpreviewswitchinginner.style.setProperty("background-image", iconpreviewopenimage);
|
||||
let switching = true;
|
||||
iconpreviewswitching.switchInterval = setInterval(() => {
|
||||
iconpreviewswitching.switchInterval = BDFDB.TimeUtils.interval(() => {
|
||||
switching = !switching;
|
||||
iconpreviewswitchinginner.style.setProperty("background-image", switching ? iconpreviewopenimage : iconpreviewclosedimage);
|
||||
},1000);
|
||||
|
@ -663,7 +663,7 @@ class ServerFolders {
|
|||
iconpreviewclosedinner.style.removeProperty("background-image");
|
||||
BDFDB.DOMUtils.addClass(iconpreviewswitching, "nopic");
|
||||
iconpreviewswitchinginner.style.removeProperty("background-image");
|
||||
clearInterval(iconpreviewswitching.switchInterval);
|
||||
BDFDB.TimeUtils.clear(iconpreviewswitching.switchInterval);
|
||||
BDFDB.NotificationUtils.toast(`Custom Icon was added to selection.`, {type:"success"});
|
||||
this.setIcons(modal, modal.querySelector(".ui-icon-picker-icon.selected").getAttribute("value"));
|
||||
}
|
||||
|
@ -819,9 +819,9 @@ class ServerFolders {
|
|||
folderinner.addEventListener("mouseenter", folderinner.ServerFoldersTooltipListener);
|
||||
}
|
||||
folderinner.ServerFoldersClickListener = () => {
|
||||
clearTimeout(this.clickedFolderTimeout);
|
||||
BDFDB.TimeUtils.clear(this.clickedFolderTimeout);
|
||||
this.clickedFolder = folderid;
|
||||
this.clickedFolderTimeout = setTimeout(() => {
|
||||
this.clickedFolderTimeout = BDFDB.TimeUtils.timeout(() => {
|
||||
delete this.clickedFolderTimeout;
|
||||
}, 3000);
|
||||
};
|
||||
|
|
|
@ -147,8 +147,8 @@ class SpellCheck {
|
|||
let [SCparent, SCindex] = BDFDB.ReactUtils.findChildren(returnvalue, {name:["NativeSpellcheckGroup", "FluxContainer(NativeSpellcheckGroup)"]});
|
||||
if (SCindex > -1) {
|
||||
if (BDFDB.ReactUtils.findValue(instance._reactInternalFiber, "spellcheckEnabled") == true) {
|
||||
clearTimeout(this.disableSpellcheckTimeout);
|
||||
this.disableSpellcheckTimeout = setTimeout(() => {
|
||||
BDFDB.TimeUtils.clear(this.disableSpellcheckTimeout);
|
||||
this.disableSpellcheckTimeout = BDFDB.TimeUtils.timeout(() => {
|
||||
BDFDB.LibraryModules.SpellCheckUtils.toggleSpellcheck();
|
||||
delete this.disableSpellcheckTimeout;
|
||||
}, 1000);
|
||||
|
@ -247,8 +247,8 @@ class SpellCheck {
|
|||
|
||||
updateSpellcheck();
|
||||
BDFDB.ListenerUtils.add(this, textarea, "keyup", e => {
|
||||
clearTimeout(textarea.spellchecktimeout);
|
||||
if (textarea.value) textarea.spellchecktimeout = setTimeout(() => {updateSpellcheck();},100);
|
||||
BDFDB.TimeUtils.clear(textarea.spellchecktimeout);
|
||||
if (textarea.value) textarea.spellchecktimeout = BDFDB.TimeUtils.timeout(() => {updateSpellcheck();},100);
|
||||
else updateSpellcheck();
|
||||
});
|
||||
BDFDB.ListenerUtils.add(this, textarea, "scroll", e => {
|
||||
|
@ -323,7 +323,7 @@ class SpellCheck {
|
|||
this.dictionary = BDFDB.DataUtils.load(this, "owndics", lang) || [];
|
||||
this.killLanguageToast();
|
||||
this.languageToast = BDFDB.NotificationUtils.toast("Grabbing dictionary (" + this.languages[lang].name + "). Please wait", {timeout:0});
|
||||
this.languageToast.interval = setInterval(() => {
|
||||
this.languageToast.interval = BDFDB.TimeUtils.interval(() => {
|
||||
this.languageToast.textContent = this.languageToast.textContent.indexOf(".....") > -1 ? "Grabbing dictionary (" + this.languages[lang].name + "). Please wait" : this.languageToast.textContent + ".";
|
||||
},500);
|
||||
this.languageToast.lang = lang
|
||||
|
@ -344,7 +344,7 @@ class SpellCheck {
|
|||
|
||||
killLanguageToast () {
|
||||
if (this.languageToast && typeof this.languageToast.close == "function") {
|
||||
clearInterval(this.languageToast.interval);
|
||||
BDFDB.TimeUtils.clear(this.languageToast.interval);
|
||||
this.languageToast.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class StalkerNotifications {
|
|||
libraryScript.setAttribute("date", performance.now());
|
||||
libraryScript.addEventListener("load", () => {this.initialize();});
|
||||
document.head.appendChild(libraryScript);
|
||||
this.libLoadTimeout = setTimeout(() => {
|
||||
this.libLoadTimeout = BDFDB.TimeUtils.timeout(() => {
|
||||
libraryScript.remove();
|
||||
require("request")("https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js", (error, response, body) => {
|
||||
if (body) {
|
||||
|
|
|
@ -372,7 +372,7 @@ class ThemeRepo {
|
|||
|
||||
this.loadThemes();
|
||||
|
||||
this.updateInterval = setInterval(() => {this.checkForNewThemes();},1000*60*30);
|
||||
this.updateInterval = BDFDB.TimeUtils.interval(() => {this.checkForNewThemes();},1000*60*30);
|
||||
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
}
|
||||
|
@ -384,8 +384,8 @@ class ThemeRepo {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
this.stopping = true;
|
||||
|
||||
clearInterval(this.updateInterval);
|
||||
clearTimeout(this.loading.timeout);
|
||||
BDFDB.TimeUtils.clear(this.updateInterval);
|
||||
BDFDB.TimeUtils.clear(this.loading.timeout);
|
||||
|
||||
BDFDB.DOMUtils.remove("iframe.discordPreview",".themerepo-notice",".bd-themerepobutton",".themerepo-loadingicon",BDFDB.dotCN.app + " > .repo-loadingwrapper:empty");
|
||||
|
||||
|
@ -397,7 +397,7 @@ class ThemeRepo {
|
|||
// begin of own functions
|
||||
|
||||
onUserSettingsCogContextMenu (instance, menu, returnvalue) {
|
||||
setImmediate(() => {for (let child of returnvalue.props.children) if (child && child.props && child.props.label == "BandagedBD" && Array.isArray(child.props.render)) {
|
||||
BDFDB.TimeUtils.timeout(() => {for (let child of returnvalue.props.children) if (child && child.props && child.props.label == "BandagedBD" && Array.isArray(child.props.render)) {
|
||||
const repoItem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
||||
label: "Theme Repo",
|
||||
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-repo-contextMenuItem`,
|
||||
|
@ -613,16 +613,16 @@ class ThemeRepo {
|
|||
if (!document.querySelector(BDFDB.dotCN.colorpicker)) {
|
||||
themeRepoModal.childNodes[0].style.setProperty("opacity", "0.85");
|
||||
themeRepoModal.childNodes[1].style.setProperty("opacity", "1");
|
||||
setTimeout(() => {for (let child of themeRepoModal.childNodes) child.style.removeProperty("transition");}, 500);
|
||||
BDFDB.TimeUtils.timeout(() => {for (let child of themeRepoModal.childNodes) child.style.removeProperty("transition");}, 500);
|
||||
}
|
||||
});
|
||||
BDFDB.ListenerUtils.addToChildren(themeRepoModal, "keyup", BDFDB.dotCN.searchbarinput, () => {
|
||||
clearTimeout(themeRepoModal.searchTimeout);
|
||||
themeRepoModal.searchTimeout = setTimeout(() => {this.sortEntries(themeRepoModal);},1000);
|
||||
BDFDB.TimeUtils.clear(themeRepoModal.searchTimeout);
|
||||
themeRepoModal.searchTimeout = BDFDB.TimeUtils.timeout(() => {this.sortEntries(themeRepoModal);},1000);
|
||||
});
|
||||
BDFDB.ListenerUtils.addToChildren(themeRepoModal, "click", BDFDB.dotCN.searchbarclear, () => {
|
||||
clearTimeout(themeRepoModal.searchTimeout);
|
||||
themeRepoModal.searchTimeout = setTimeout(() => {this.sortEntries(themeRepoModal);},1000);
|
||||
BDFDB.TimeUtils.clear(themeRepoModal.searchTimeout);
|
||||
themeRepoModal.searchTimeout = BDFDB.TimeUtils.timeout(() => {this.sortEntries(themeRepoModal);},1000);
|
||||
});
|
||||
BDFDB.ListenerUtils.addToChildren(themeRepoModal, "change", ".hide-checkbox", e => {
|
||||
themeRepoModal.updateHidden = true;
|
||||
|
@ -748,8 +748,8 @@ class ThemeRepo {
|
|||
}
|
||||
}
|
||||
let inputs = container.querySelectorAll(".varinput"), updateTimeout, updatePreview = () => {
|
||||
clearTimeout(updateTimeout);
|
||||
updateTimeout = setTimeout(() => {
|
||||
BDFDB.TimeUtils.clear(updateTimeout);
|
||||
updateTimeout = BDFDB.TimeUtils.timeout(() => {
|
||||
let css = data.fullcss;
|
||||
for (let input of inputs) {
|
||||
let oldvalue = input.getAttribute("placeholder");
|
||||
|
@ -817,7 +817,7 @@ class ThemeRepo {
|
|||
entry.querySelector(".btn-download").addEventListener("click", e => {
|
||||
setEntryState(0);
|
||||
this.downloadTheme(data);
|
||||
if (themeRepoModal.querySelector("#input-rnmstart").checked) setTimeout(() => {this.applyTheme(data);},3000);
|
||||
if (themeRepoModal.querySelector("#input-rnmstart").checked) BDFDB.TimeUtils.timeout(() => {this.applyTheme(data);},3000);
|
||||
});
|
||||
entry.querySelector(".previewCheckbox").addEventListener("click", e => {
|
||||
themeRepoModal.querySelector(".generator-select " + BDFDB.dotCN.select).setAttribute('value', "-----");
|
||||
|
@ -902,10 +902,10 @@ class ThemeRepo {
|
|||
}
|
||||
this.foundThemes = this.grabbedThemes.concat(ownlist);
|
||||
|
||||
this.loading = {is:true, timeout:setTimeout(() => {
|
||||
clearTimeout(this.loading.timeout);
|
||||
this.loading = {is:true, timeout:BDFDB.TimeUtils.timeout(() => {
|
||||
BDFDB.TimeUtils.clear(this.loading.timeout);
|
||||
if (this.started) {
|
||||
if (this.loading.is && this.loading.amount < 4) setTimeout(() => {this.loadThemes();},10000);
|
||||
if (this.loading.is && this.loading.amount < 4) BDFDB.TimeUtils.timeout(() => {this.loadThemes();},10000);
|
||||
this.loading = {is: false, timeout:null, amount:this.loading.amount};
|
||||
}
|
||||
},1200000), amount:this.loading.amount+1};
|
||||
|
@ -923,12 +923,12 @@ class ThemeRepo {
|
|||
|
||||
getThemeInfo(() => {
|
||||
if (!this.started) {
|
||||
clearTimeout(this.loading.timeout);
|
||||
BDFDB.TimeUtils.clear(this.loading.timeout);
|
||||
return;
|
||||
}
|
||||
BDFDB.DOMUtils.remove(loadingicon, ".themerepo-loadingicon");
|
||||
if (!loadingiconwrapper.firstChild) BDFDB.DOMUtils.remove(loadingiconwrapper);
|
||||
clearTimeout(this.loading.timeout);
|
||||
BDFDB.TimeUtils.clear(this.loading.timeout);
|
||||
this.loading = {is:false, timeout:null, amount:this.loading.amount};
|
||||
console.log(`%c[${this.name}]%c`, "color: #3a71c1; font-weight: 700;", "", "Finished fetching Themes.");
|
||||
if (document.querySelector(".bd-themerepobutton")) BDFDB.NotificationUtils.toast(`Finished fetching Themes.`, {type:"success"});
|
||||
|
|
|
@ -72,7 +72,7 @@ class TimedLightDarkMode {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
this.stopping = true;
|
||||
|
||||
clearInterval(this.checkInterval);
|
||||
BDFDB.TimeUtils.clear(this.checkInterval);
|
||||
|
||||
BDFDB.DOMUtils.remove(".TLDM-settingsbox");
|
||||
|
||||
|
@ -103,7 +103,7 @@ class TimedLightDarkMode {
|
|||
}
|
||||
|
||||
startInterval () {
|
||||
clearInterval(this.checkInterval);
|
||||
BDFDB.TimeUtils.clear(this.checkInterval);
|
||||
if (BDFDB.DataUtils.get(this, "settings", "running")) {
|
||||
var values = BDFDB.DataUtils.get(this, "values");
|
||||
var inverted = values.timer1 > values.timer2;
|
||||
|
@ -117,7 +117,7 @@ class TimedLightDarkMode {
|
|||
else this.changeTheme(this.checkTime(timer2LOW, timer2HIGH, [currenthours, currentminutes]));
|
||||
};
|
||||
check();
|
||||
this.checkInterval = setInterval(check, 60000);
|
||||
this.checkInterval = BDFDB.TimeUtils.interval(check, 60000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,8 +68,8 @@ class WriteUpperCase {
|
|||
var textarea = wrapper.querySelector("textarea");
|
||||
if (!textarea) return;
|
||||
BDFDB.ListenerUtils.add(this, textarea, "keyup", () => {
|
||||
clearTimeout(textarea.WriteUpperCaseTimeout);
|
||||
textarea.WriteUpperCaseTimeout = setTimeout(() => {
|
||||
BDFDB.TimeUtils.clear(textarea.WriteUpperCaseTimeout);
|
||||
textarea.WriteUpperCaseTimeout = BDFDB.TimeUtils.timeout(() => {
|
||||
let string = textarea.value;
|
||||
if (string.length > 0) {
|
||||
let newstring = string;
|
||||
|
|
Loading…
Reference in New Issue