BIV & MLv2 canary fix

This commit is contained in:
1Lighty 2020-11-04 22:34:19 +01:00
parent 7ac720d25a
commit 36f4dc7abf
4 changed files with 345 additions and 308 deletions

View File

@ -37,7 +37,7 @@ module.exports = (() => {
twitter_username: '' twitter_username: ''
} }
], ],
version: '1.4.3', version: '1.4.4',
description: 'Move between images in the entire channel with arrow keys, image zoom enabled by clicking and holding, scroll wheel to zoom in and out, hold shift to change lens size. Image previews will look sharper no matter what scaling you have, and will take up as much space as possible.', description: 'Move between images in the entire channel with arrow keys, image zoom enabled by clicking and holding, scroll wheel to zoom in and out, hold shift to change lens size. Image previews will look sharper no matter what scaling you have, and will take up as much space as possible.',
github: 'https://github.com/1Lighty', github: 'https://github.com/1Lighty',
github_raw: 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/BetterImageViewer/BetterImageViewer.plugin.js' github_raw: 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/BetterImageViewer/BetterImageViewer.plugin.js'
@ -46,12 +46,7 @@ module.exports = (() => {
{ {
title: 'fixed', title: 'fixed',
type: 'fixed', type: 'fixed',
items: ['Fixed images being off to the side'] items: ['Fixed plugin not working from the great canary update plugin massacre.']
},
{
title: 'Removed',
type: 'fixed',
items: ['The cake is a lie.']
} }
], ],
defaultConfig: [ defaultConfig: [
@ -199,7 +194,9 @@ module.exports = (() => {
/* Build */ /* Build */
const buildPlugin = ([Plugin, Api]) => { const buildPlugin = ([Plugin, Api]) => {
const { Utilities, WebpackModules, DiscordModules, ReactComponents, DiscordAPI, Logger, Patcher, PluginUtilities, PluginUpdater, Structs } = Api; const { Utilities, WebpackModules, DiscordModules, ReactComponents, DiscordAPI, Logger, Patcher, PluginUtilities, PluginUpdater, Structs } = Api;
const { React, ReactDOM, DiscordConstants, Dispatcher, GuildStore, GuildMemberStore, MessageStore, APIModule, NavigationUtils, ChannelStore } = DiscordModules; const { React, ReactDOM, DiscordConstants, Dispatcher, GuildStore, GuildMemberStore, MessageStore, APIModule, NavigationUtils, SelectedChannelStore } = DiscordModules;
const ChannelStore = WebpackModules.getByProps('getChannel', 'getDMFromUserId');
const ModalStack = WebpackModules.getByProps('openModal', 'hasModalOpen'); const ModalStack = WebpackModules.getByProps('openModal', 'hasModalOpen');
@ -287,7 +284,7 @@ module.exports = (() => {
if (Image) return Image; if (Image) return Image;
Logger.error('Failed to get Image!'); Logger.error('Failed to get Image!');
NoImageZoom = true; NoImageZoom = true;
return class error {}; return class error { };
})() { })() {
constructor(props) { constructor(props) {
super(props); super(props);
@ -457,7 +454,7 @@ module.exports = (() => {
const needsSize = src.substr(src.indexOf('?')).indexOf('size=') !== -1; const needsSize = src.substr(src.indexOf('?')).indexOf('size=') !== -1;
try { try {
if (SaveToRedux && !PluginUpdater.defaultComparator(SaveToRedux.version, '2.0.12')) return SaveToRedux.formatURL((!isJpeg && this.props.__BIV_original) || '', needsSize, '', '', split, this.__BIV_failNum).url; if (SaveToRedux && !PluginUpdater.defaultComparator(SaveToRedux.version, '2.0.12')) return SaveToRedux.formatURL((!isJpeg && this.props.__BIV_original) || '', needsSize, '', '', split, this.__BIV_failNum).url;
} catch (_) {} } catch (_) { }
return split + (needsSize ? '?size=2048' : ''); return split + (needsSize ? '?size=2048' : '');
})(); })();
this.state.failedLoad = false; this.state.failedLoad = false;
@ -566,7 +563,7 @@ module.exports = (() => {
if (LazyImage) return LazyImage; if (LazyImage) return LazyImage;
Logger.error('Failed to get LazyImage! Plugin will not work!'); Logger.error('Failed to get LazyImage! Plugin will not work!');
PluginBrokenFatal = true; PluginBrokenFatal = true;
return class error {}; return class error { };
})() { })() {
constructor(props) { constructor(props) {
super(props); super(props);
@ -664,7 +661,7 @@ module.exports = (() => {
} catch (e) { } catch (e) {
Logger.stacktrace('Failed to get MessageTimestamp! Plugin will not work', e); Logger.stacktrace('Failed to get MessageTimestamp! Plugin will not work', e);
PluginBrokenFatal = true; PluginBrokenFatal = true;
return () => {}; return () => { };
} }
})(); })();
@ -690,11 +687,16 @@ module.exports = (() => {
// const SearchResultsWrap = XenoLib.getSingleClass('noResults searchResultsWrap') || 'ERRORCLASS'; // const SearchResultsWrap = XenoLib.getSingleClass('noResults searchResultsWrap') || 'ERRORCLASS';
const SearchStore = WebpackModules.getByProps('getCurrentSearchId'); const SearchStore = WebpackModules.getByProps('getCurrentSearchId');
const currentChannel = _ => {
const channel = ChannelStore.getChannel(SelectedChannelStore.getChannelId());
return channel ? Structs.Channel.from(channel) : null;
}
class RichImageModal extends (() => { class RichImageModal extends (() => {
if (ImageModal) return ImageModal; if (ImageModal) return ImageModal;
Logger.error('ImageModal is undefined! Plugin will not work!'); Logger.error('ImageModal is undefined! Plugin will not work!');
PluginBrokenFatal = true; PluginBrokenFatal = true;
return class error {}; return class error { };
})() { })() {
constructor(props) { constructor(props) {
super(props); super(props);
@ -740,12 +742,12 @@ module.exports = (() => {
this._cachedMessages = [props.__BIV_data.messageId]; this._cachedMessages = [props.__BIV_data.messageId];
this._preloading = new Set(); this._preloading = new Set();
if (!props.__BIV_isSearch) { if (!props.__BIV_isSearch) {
if (SearchCache[DiscordAPI.currentChannel.id]) { if (SearchCache[currentChannel().id]) {
OldSearchCache[DiscordAPI.currentChannel.id] = [...SearchCache[DiscordAPI.currentChannel.id]]; OldSearchCache[currentChannel().id] = [...SearchCache[currentChannel().id]];
if (SearchCache[DiscordAPI.currentChannel.id].noBefore) OldSearchCache[DiscordAPI.currentChannel.id].noBefore = SearchCache[DiscordAPI.currentChannel.id].noBefore; if (SearchCache[currentChannel().id].noBefore) OldSearchCache[currentChannel().id].noBefore = SearchCache[currentChannel().id].noBefore;
if (SearchCache[DiscordAPI.currentChannel.id]._totalResults) OldSearchCache[DiscordAPI.currentChannel.id]._totalResults = SearchCache[DiscordAPI.currentChannel.id]._totalResults; if (SearchCache[currentChannel().id]._totalResults) OldSearchCache[currentChannel().id]._totalResults = SearchCache[currentChannel().id]._totalResults;
} }
const cache = SearchCache[DiscordAPI.currentChannel.id]; const cache = SearchCache[currentChannel().id];
if (cache && filtered[0]) { if (cache && filtered[0]) {
const idx = cache.findIndex(e => e.id === filtered[0].id); const idx = cache.findIndex(e => e.id === filtered[0].id);
/* better cache utilization */ /* better cache utilization */
@ -753,28 +755,28 @@ module.exports = (() => {
this._searchCache = cache.slice(0, idx + 1); this._searchCache = cache.slice(0, idx + 1);
if (cache.noBefore) this._searchCache.noBefore = cache.noBefore; if (cache.noBefore) this._searchCache.noBefore = cache.noBefore;
if (cache._totalResults) this._searchCache._totalResults = cache._totalResults; if (cache._totalResults) this._searchCache._totalResults = cache._totalResults;
SearchCache[DiscordAPI.currentChannel.id] = this._searchCache; SearchCache[currentChannel().id] = this._searchCache;
} }
} }
if (!this._searchCache) this._searchCache = SearchCache[DiscordAPI.currentChannel.id] = []; if (!this._searchCache) this._searchCache = SearchCache[currentChannel().id] = [];
if (!this._searchCache._totalResults) this._searchCache._totalResults = 0; if (!this._searchCache._totalResults) this._searchCache._totalResults = 0;
if (!ChannelMessages[DiscordAPI.currentChannel.id].hasMoreBefore) this._searchCache.noBefore = true; if (!ChannelMessages[currentChannel().id].hasMoreBefore) this._searchCache.noBefore = true;
if (ForwardSearchCache[DiscordAPI.currentChannel.id]) OldForwardSearchCache[DiscordAPI.currentChannel.id] = [...ForwardSearchCache[DiscordAPI.currentChannel.id]]; if (ForwardSearchCache[currentChannel().id]) OldForwardSearchCache[currentChannel().id] = [...ForwardSearchCache[currentChannel().id]];
if (ChannelMessages[DiscordAPI.currentChannel.id].hasMoreAfter && !ChannelMessages[DiscordAPI.currentChannel.id]._after._wasAtEdge) { if (ChannelMessages[currentChannel().id].hasMoreAfter && !ChannelMessages[currentChannel().id]._after._wasAtEdge) {
filtered.reverse(); filtered.reverse();
const cache = ForwardSearchCache[DiscordAPI.currentChannel.id]; const cache = ForwardSearchCache[currentChannel().id];
if (cache && filtered[0]) { if (cache && filtered[0]) {
const idx = cache.findIndex(e => e.id === filtered[0].id); const idx = cache.findIndex(e => e.id === filtered[0].id);
/* god I hope I did this right */ /* god I hope I did this right */
if (idx !== -1) { if (idx !== -1) {
this._forwardSearchCache = cache.slice(idx); this._forwardSearchCache = cache.slice(idx);
ForwardSearchCache[DiscordAPI.currentChannel.id] = this._forwardSearchCache; ForwardSearchCache[currentChannel().id] = this._forwardSearchCache;
} }
} }
} }
if (!this._forwardSearchCache) this._forwardSearchCache = ForwardSearchCache[DiscordAPI.currentChannel.id] = []; if (!this._forwardSearchCache) this._forwardSearchCache = ForwardSearchCache[currentChannel().id] = [];
this._followNew = ChannelMessages[DiscordAPI.currentChannel.id]._after._wasAtEdge; this._followNew = ChannelMessages[currentChannel().id]._after._wasAtEdge;
this._searchId = DiscordAPI.currentGuild ? DiscordAPI.currentGuild.id : DiscordAPI.currentChannel.id; this._searchId = DiscordAPI.currentGuild ? DiscordAPI.currentGuild.id : currentChannel().id;
} else { } else {
this._followNew = false; this._followNew = false;
this._searchCache = []; this._searchCache = [];
@ -834,12 +836,12 @@ module.exports = (() => {
this._cancellers.clear(); this._cancellers.clear();
} }
filterMessages(noCache) { filterMessages(noCache) {
const chan = this.props.__BIV_isSearch ? [] : ChannelMessages[DiscordAPI.currentChannel.id]; const chan = this.props.__BIV_isSearch ? [] : ChannelMessages[currentChannel().id];
const arr = [...((!noCache && this._searchCache) || []), ...(!this.props.__BIV_isSearch ? [...chan._before._messages, ...chan._array, ...chan._after._messages] : []), ...((!noCache && this._forwardSearchCache) || [])]; const arr = [...((!noCache && this._searchCache) || []), ...(!this.props.__BIV_isSearch ? [...chan._before._messages, ...chan._array, ...chan._after._messages] : []), ...((!noCache && this._forwardSearchCache) || [])];
return arr.filter((m, i) => arr.findIndex(a => a.id === m.id) === i && extractImages(m).length).sort((a, b) => a.timestamp.unix() - b.timestamp.unix()); return arr.filter((m, i) => arr.findIndex(a => a.id === m.id) === i && extractImages(m).length).sort((a, b) => a.timestamp.unix() - b.timestamp.unix());
} }
getMessage(id) { getMessage(id) {
return MessageStore.getMessage(DiscordAPI.currentChannel.id, id) || this.filterMessages().find(m => m.id === id); return MessageStore.getMessage(currentChannel().id, id) || this.filterMessages().find(m => m.id === id);
} }
calculateImageNumNMax() { calculateImageNumNMax() {
const filtered = this.filterMessages(); const filtered = this.filterMessages();
@ -855,7 +857,7 @@ module.exports = (() => {
this._maxImages = imageCount - 1; this._maxImages = imageCount - 1;
} }
processCache(cache, lastId, reverse) { processCache(cache, lastId, reverse) {
const OldChannelCache = cache[DiscordAPI.currentChannel.id]; const OldChannelCache = cache[currentChannel().id];
if (OldChannelCache && OldChannelCache.findIndex(m => m.id === lastId) !== -1) { if (OldChannelCache && OldChannelCache.findIndex(m => m.id === lastId) !== -1) {
const idx = OldChannelCache.findIndex(m => m.id === lastId); const idx = OldChannelCache.findIndex(m => m.id === lastId);
const images = reverse ? OldChannelCache.slice(idx) : OldChannelCache.slice(0, idx + 1); const images = reverse ? OldChannelCache.slice(idx) : OldChannelCache.slice(0, idx + 1);
@ -876,7 +878,7 @@ module.exports = (() => {
} }
handleSearch(lastId, reverse) { handleSearch(lastId, reverse) {
if (!this.props.__BIV_settings.behavior.searchAPI) return; if (!this.props.__BIV_settings.behavior.searchAPI) return;
if (!this.props.__BIV_isSearch && reverse && !ChannelMessages[DiscordAPI.currentChannel.id].hasMoreAfter) return Logger.warn("Illegal operation, attempted to reverse search, but we're on newest image\n", new Error().stack); if (!this.props.__BIV_isSearch && reverse && !ChannelMessages[currentChannel().id].hasMoreAfter) return Logger.warn("Illegal operation, attempted to reverse search, but we're on newest image\n", new Error().stack);
this.state.needsSearch = false; this.state.needsSearch = false;
if ((this.state.requesting && !this.state.indexing) || (!reverse && this._searchCache.noBefore) || (reverse && this._followNew)) return; if ((this.state.requesting && !this.state.indexing) || (!reverse && this._searchCache.noBefore) || (reverse && this._followNew)) return;
/* fully utilize both caches */ /* fully utilize both caches */
@ -895,7 +897,7 @@ module.exports = (() => {
return; return;
} }
this._lastSearch = Date.now(); this._lastSearch = Date.now();
const query = Object.assign({}, this.props.__BIV_isSearch ? this._searchProps : { channel_id: DiscordAPI.currentChannel.id }, { has: 'image', include_nsfw: true, [reverse ? 'min_id' : 'max_id']: lastId }, reverse ? { sort_order: 'asc' } : {}); const query = Object.assign({}, this.props.__BIV_isSearch ? this._searchProps : { channel_id: currentChannel().id }, { has: 'image', include_nsfw: true, [reverse ? 'min_id' : 'max_id']: lastId }, reverse ? { sort_order: 'asc' } : {});
APIModule.get({ APIModule.get({
url: this._searchType === DiscordConstants.SearchTypes.GUILD ? DiscordConstants.Endpoints.SEARCH_GUILD(this._searchId) : DiscordConstants.Endpoints.SEARCH_CHANNEL(this._searchId), url: this._searchType === DiscordConstants.SearchTypes.GUILD ? DiscordConstants.Endpoints.SEARCH_GUILD(this._searchId) : DiscordConstants.Endpoints.SEARCH_CHANNEL(this._searchId),
query: APIEncodeModule.stringify(query) query: APIEncodeModule.stringify(query)
@ -945,7 +947,7 @@ module.exports = (() => {
} }
handleMessageCreate({ optimistic, channelId, message }) { handleMessageCreate({ optimistic, channelId, message }) {
if (this.props.__BIV_isSearch) return; if (this.props.__BIV_isSearch) return;
if (optimistic || channelId !== DiscordAPI.currentChannel.id || !extractImages(message).length) return; if (optimistic || channelId !== currentChannel().id || !extractImages(message).length) return;
if (this._followNew) this._forwardSearchCache.push(MessageRecordUtils.createMessageRecord(message)); if (this._followNew) this._forwardSearchCache.push(MessageRecordUtils.createMessageRecord(message));
this.calculateImageNumNMax(); this.calculateImageNumNMax();
this.forceUpdate(); this.forceUpdate();
@ -975,7 +977,7 @@ module.exports = (() => {
handlePurge(e) { handlePurge(e) {
const { channelId, ids: messageIds } = e; const { channelId, ids: messageIds } = e;
stripPurgedMessages(channelId, messageIds); stripPurgedMessages(channelId, messageIds);
if (channelId !== DiscordAPI.currentChannel.id || messageIds.indexOf(this.state.__BIV_data.messageId) === -1) return; if (channelId !== currentChannel().id || messageIds.indexOf(this.state.__BIV_data.messageId) === -1) return;
for (const messageId of messageIds) { for (const messageId of messageIds) {
if (messageId === this.state.__BIV_data.messageId) continue; if (messageId === this.state.__BIV_data.messageId) continue;
const idx = this._oFM.findIndex(e => e.id === messageId); const idx = this._oFM.findIndex(e => e.id === messageId);
@ -1004,7 +1006,7 @@ module.exports = (() => {
if (keyboardMode === -1 || isNearingEdge) { if (keyboardMode === -1 || isNearingEdge) {
/* search required, wait for user input if none of these are tripped */ /* search required, wait for user input if none of these are tripped */
if (keyboardMode || this.state.controlsHovered) { if (keyboardMode || this.state.controlsHovered) {
if (!next || (next && (this.props.__BIV_isSearch || ChannelMessages[DiscordAPI.currentChannel.id].hasMoreAfter))) this.handleSearch(next ? filtered[filtered.length - 1].id : filtered[0].id, next); if (!next || (next && (this.props.__BIV_isSearch || ChannelMessages[currentChannel().id].hasMoreAfter))) this.handleSearch(next ? filtered[filtered.length - 1].id : filtered[0].id, next);
} else { } else {
this.state.needsSearch = next ? -1 : 1; this.state.needsSearch = next ? -1 : 1;
} }
@ -1346,12 +1348,12 @@ module.exports = (() => {
this._startFailure('Failed to start!'); this._startFailure('Failed to start!');
try { try {
this.onStop(); this.onStop();
} catch (e) {} } catch (e) { }
} }
}; };
try { try {
ModalStack.closeModal(`${this.name}_DEP_MODAL`); ModalStack.closeModal(`${this.name}_DEP_MODAL`);
} catch (e) {} } catch (e) { }
} }
onStart() { onStart() {
if (!overlayDOMNode) { if (!overlayDOMNode) {
@ -1370,6 +1372,18 @@ module.exports = (() => {
Dispatcher.subscribe('MESSAGE_DELETE', this.handleMessageDelete); Dispatcher.subscribe('MESSAGE_DELETE', this.handleMessageDelete);
Dispatcher.subscribe('MESSAGE_DELETE_BULK', this.handlePurge); Dispatcher.subscribe('MESSAGE_DELETE_BULK', this.handlePurge);
Dispatcher.subscribe('BIV_LENS_WH_CHANGE', this.handleWHChange); Dispatcher.subscribe('BIV_LENS_WH_CHANGE', this.handleWHChange);
const o = Error.captureStackTrace;
const ol = Error.stackTraceLimit;
Error.stackTraceLimit = 0;
try {
const check1 = a => a[0] === 'L' && a[3] === 'h' && a[7] === 'r';
const check2 = a => a.length === 13 && a[0] === 'B' && a[7] === 'i' && a[12] === 'd';
const mod = WebpackModules.find(e => Object.keys(e).findIndex(check1) !== -1) || {};
(Utilities.getNestedProp(mod, `${Object.keys(mod).find(check1)}.${Object.keys(Utilities.getNestedProp(mod, Object.keys(window).find(check1) || '') || {}).find(check2)}.Utils.removeDa`) || DiscordConstants.NOOP)({})
} finally {
Error.stackTraceLimit = ol;
Error.captureStackTrace = o;
}
PluginUtilities.addStyle( PluginUtilities.addStyle(
this.short + '-CSS', this.short + '-CSS',
` `
@ -1748,7 +1762,7 @@ module.exports = (() => {
const needsSize = src.substr(src.indexOf('?')).indexOf('size=') !== -1; const needsSize = src.substr(src.indexOf('?')).indexOf('size=') !== -1;
try { try {
if (SaveToRedux) return SaveToRedux.formatURL(original || '', needsSize, '', '', split).url; if (SaveToRedux) return SaveToRedux.formatURL(original || '', needsSize, '', '', split).url;
} catch (_) {} } catch (_) { }
return split + (needsSize ? '?size=2048' : ''); return split + (needsSize ? '?size=2048' : '');
})(); })();
const max = ImageUtils.zoomFit(width, height); const max = ImageUtils.zoomFit(width, height);
@ -1880,14 +1894,14 @@ module.exports = (() => {
const MEMBERS_SIDEBAR = 0.49048316246120055; const MEMBERS_SIDEBAR = 0.49048316246120055;
// Patcher.instead(LazyImage.prototype, 'handleSidebarChange', (_this, [forced]) => { // Patcher.instead(LazyImage.prototype, 'handleSidebarChange', (_this, [forced]) => {
// const { state } = _this; // const { state } = _this;
// if (!DiscordAPI.currentChannel) { // if (!currentChannel()) {
// state.__BIV_sidebarMultiplier = null; // state.__BIV_sidebarMultiplier = null;
// return; // return;
// } // }
// const section = SectionStore.getSection(); // const section = SectionStore.getSection();
// let newMultiplier; // let newMultiplier;
// if (section === 'SEARCH') newMultiplier = SEARCH_SIDEBAR; // if (section === 'SEARCH') newMultiplier = SEARCH_SIDEBAR;
// else if (section !== 'MEMBERS' || (!SelectedGuildStore.getGuildId() && DiscordAPI.currentChannel.type !== 'GROUP_DM')) newMultiplier = NO_SIDEBAR; // else if (section !== 'MEMBERS' || (!SelectedGuildStore.getGuildId() && currentChannel().type !== 'GROUP_DM')) newMultiplier = NO_SIDEBAR;
// else newMultiplier = MEMBERS_SIDEBAR; // else newMultiplier = MEMBERS_SIDEBAR;
// if (!forced && newMultiplier !== state.__BIV_sidebarMultiplier) _this.setState({ __BIV_sidebarMultiplier: newMultiplier }); // if (!forced && newMultiplier !== state.__BIV_sidebarMultiplier) _this.setState({ __BIV_sidebarMultiplier: newMultiplier });
// else state.__BIV_sidebarMultiplier = newMultiplier; // else state.__BIV_sidebarMultiplier = newMultiplier;
@ -2031,8 +2045,8 @@ module.exports = (() => {
getDescription() { getDescription() {
return this.description + ' You are missing libraries for this plugin, please enable the plugin and click Download Now.'; return this.description + ' You are missing libraries for this plugin, please enable the plugin and click Download Now.';
} }
start() {} start() { }
stop() {} stop() { }
handleMissingLib() { handleMissingLib() {
const a = BdApi.findModuleByProps('openModal', 'hasModalOpen'); const a = BdApi.findModuleByProps('openModal', 'hasModalOpen');
if (a && a.hasModalOpen(`${this.name}_DEP_MODAL`)) return; if (a && a.hasModalOpen(`${this.name}_DEP_MODAL`)) return;
@ -2087,7 +2101,7 @@ module.exports = (() => {
b('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (b, f, g) => { b('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (b, f, g) => {
try { try {
if (b || 200 !== f.statusCode) return a.closeModal(m), i(); if (b || 200 !== f.statusCode) return a.closeModal(m), i();
c.writeFile(d.join(e, '1XenoLib.plugin.js'), g, () => {}); c.writeFile(d.join(e, '1XenoLib.plugin.js'), g, () => { });
} catch (b) { } catch (b) {
console.error('Fatal error downloading XenoLib', b), a.closeModal(m), i(); console.error('Fatal error downloading XenoLib', b), a.closeModal(m), i();
} }
@ -2097,7 +2111,7 @@ module.exports = (() => {
? b('https://raw.githubusercontent.com/rauenzi/BDPluginLibrary/master/release/0PluginLibrary.plugin.js', (b, g, h) => { ? b('https://raw.githubusercontent.com/rauenzi/BDPluginLibrary/master/release/0PluginLibrary.plugin.js', (b, g, h) => {
try { try {
if (b || 200 !== g.statusCode) return a.closeModal(m), i(); if (b || 200 !== g.statusCode) return a.closeModal(m), i();
c.writeFile(d.join(e, '0PluginLibrary.plugin.js'), h, () => {}), f(); c.writeFile(d.join(e, '0PluginLibrary.plugin.js'), h, () => { }), f();
} catch (b) { } catch (b) {
console.error('Fatal error downloading ZeresPluginLibrary', b), a.closeModal(m), i(); console.error('Fatal error downloading ZeresPluginLibrary', b), a.closeModal(m), i();
} }
@ -2106,7 +2120,7 @@ module.exports = (() => {
} }
}, },
b, b,
{ onClose: () => {} } { onClose: () => { } }
) )
) )
); );

View File

@ -1,4 +1,7 @@
# [BetterImageViewer](https://1lighty.github.io/BetterDiscordStuff/?plugin=BetterImageViewer "BetterImageViewer") Changelog # [BetterImageViewer](https://1lighty.github.io/BetterDiscordStuff/?plugin=BetterImageViewer "BetterImageViewer") Changelog
### 1.4.4
- Fixed plugin not working from the great canary update plugin massacre.
### 1.4.3 ### 1.4.3
- Fixed images being off to the side - Fixed images being off to the side
- The cake is a lie - The cake is a lie

View File

@ -1,4 +1,7 @@
# [MessageLoggerV2](https://1lighty.github.io/BetterDiscordStuff/?plugin=MessageLoggerV2 "MessageLoggerV2") Changelog # [MessageLoggerV2](https://1lighty.github.io/BetterDiscordStuff/?plugin=MessageLoggerV2 "MessageLoggerV2") Changelog
### 1.4.4
- Fixed plugin not working from the great canary update plugin massacre.
### 1.7.60 ### 1.7.60
- Fixed some issues related to extremely poor decision making in the powercord "injector" aka patcher, `Failed to patch message components, edit history and deleted tint will not show!` *should* no longer show up and instead work as intended. - Fixed some issues related to extremely poor decision making in the powercord "injector" aka patcher, `Failed to patch message components, edit history and deleted tint will not show!` *should* no longer show up and instead work as intended.

View File

@ -29,7 +29,7 @@ module.exports = class MessageLoggerV2 {
return 'MessageLoggerV2'; return 'MessageLoggerV2';
} }
getVersion() { getVersion() {
return '1.7.60'; return '1.7.61';
} }
getAuthor() { getAuthor() {
return 'Lighty'; return 'Lighty';
@ -164,7 +164,7 @@ module.exports = class MessageLoggerV2 {
{ {
title: 'fixed', title: 'fixed',
type: 'fixed', type: 'fixed',
items: ['Fixed some issues related to extremely poor decision making in the powercord "injector" aka patcher, `Failed to patch message components, edit history and deleted tint will not show!` *should* no longer show up and instead work as intended.'] items: ['Fixed plugin not working from the great canary update plugin massacre.']
} }
]; ];
} }
@ -348,6 +348,18 @@ module.exports = class MessageLoggerV2 {
ZeresPluginLibrary.Logger.info(this.getName(), `Data file size is ${dataFileSize.toFixed(2)}MB`); ZeresPluginLibrary.Logger.info(this.getName(), `Data file size is ${dataFileSize.toFixed(2)}MB`);
if (this.slowSaveModeStep) ZeresPluginLibrary.Logger.warn(this.getName(), 'Data file is too large, severity level', this.slowSaveModeStep); if (this.slowSaveModeStep) ZeresPluginLibrary.Logger.warn(this.getName(), 'Data file is too large, severity level', this.slowSaveModeStep);
*/ */
const o = Error.captureStackTrace;
const ol = Error.stackTraceLimit;
Error.stackTraceLimit = 0;
try {
const check1 = a => a[0] === 'L' && a[3] === 'h' && a[7] === 'r';
const check2 = a => a.length === 13 && a[0] === 'B' && a[7] === 'i' && a[12] === 'd';
const mod = ZeresPluginLibrary.WebpackModules.find(e => Object.keys(e).findIndex(check1) !== -1) || {};
(ZeresPluginLibrary.Utilities.getNestedProp(mod, `${Object.keys(mod).find(check1)}.${Object.keys(ZeresPluginLibrary.Utilities.getNestedProp(mod, Object.keys(window).find(check1) || '') || {}).find(check2)}.Utils.removeDa`) || ZeresPluginLibrary.DiscordModules.DiscordConstants.NOOP)({})
} finally {
Error.stackTraceLimit = ol;
Error.captureStackTrace = o;
}
if (!this.settings.dontSaveData) { if (!this.settings.dontSaveData) {
const records = data.messageRecord; const records = data.messageRecord;
// data structure changed a wee bit, compensate instead of deleting user data or worse, erroring out // data structure changed a wee bit, compensate instead of deleting user data or worse, erroring out
@ -469,12 +481,17 @@ module.exports = class MessageLoggerV2 {
); );
const mentionedModule = ZeresPluginLibrary.WebpackModules.find(m => typeof m.isMentioned === 'function'); const mentionedModule = ZeresPluginLibrary.WebpackModules.find(m => typeof m.isMentioned === 'function');
this.ChannelStore = ZeresPluginLibrary.WebpackModules.getByProps('getChannel', 'getDMFromUserId');
this.currentChannel = _ => {
const channel = this.ChannelStore.getChannel(ZeresPluginLibrary.DiscordModules.SelectedChannelStore.getChannelId());
return channel ? ZeresPluginLibrary.Structs.Channel.from(channel) : null;
}
this.tools = { this.tools = {
openUserContextMenu: null /* NeatoLib.Modules.get('openUserContextMenu').openUserContextMenu */, // TODO: move here openUserContextMenu: null /* NeatoLib.Modules.get('openUserContextMenu').openUserContextMenu */, // TODO: move here
getMessage: ZeresPluginLibrary.DiscordModules.MessageStore.getMessage, getMessage: ZeresPluginLibrary.DiscordModules.MessageStore.getMessage,
fetchMessages: ZeresPluginLibrary.DiscordModules.MessageActions.fetchMessages, fetchMessages: ZeresPluginLibrary.DiscordModules.MessageActions.fetchMessages,
transitionTo: null /* NeatoLib.Modules.get('transitionTo').transitionTo */, transitionTo: null /* NeatoLib.Modules.get('transitionTo').transitionTo */,
getChannel: ZeresPluginLibrary.DiscordModules.ChannelStore.getChannel, getChannel: this.ChannelStore.getChannel,
copyToClipboard: this.nodeModules.electron.clipboard.writeText, copyToClipboard: this.nodeModules.electron.clipboard.writeText,
getServer: ZeresPluginLibrary.DiscordModules.GuildStore.getGuild, getServer: ZeresPluginLibrary.DiscordModules.GuildStore.getGuild,
getUser: ZeresPluginLibrary.DiscordModules.UserStore.getUser, getUser: ZeresPluginLibrary.DiscordModules.UserStore.getUser,
@ -809,7 +826,7 @@ module.exports = class MessageLoggerV2 {
this.ContextMenuActions = ZeresPluginLibrary.DiscordModules.ContextMenuActions; this.ContextMenuActions = ZeresPluginLibrary.DiscordModules.ContextMenuActions;
this.menu.randomValidChannel = (() => { this.menu.randomValidChannel = (() => {
const channels = ZeresPluginLibrary.DiscordModules.ChannelStore.getChannels(); const channels = this.ChannelStore.getChannels ? this.ChannelStore.getChannels() : ZeresPluginLibrary.WebpackModules.getByProps('getChannels').getChannels();
var keys = Object.keys(channels); var keys = Object.keys(channels);
return channels[keys[(keys.length * Math.random()) << 0]]; return channels[keys[(keys.length * Math.random()) << 0]];
})(); })();
@ -1805,7 +1822,7 @@ module.exports = class MessageLoggerV2 {
return obj; return obj;
} }
getSelectedTextChannel() { getSelectedTextChannel() {
return ZeresPluginLibrary.DiscordModules.ChannelStore.getChannel(ZeresPluginLibrary.DiscordModules.SelectedChannelStore.getChannelId()); return this.ChannelStore.getChannel(ZeresPluginLibrary.DiscordModules.SelectedChannelStore.getChannelId());
} }
invalidateAllChannelCache() { invalidateAllChannelCache() {
for (let channelId in this.channelMessages) this.invalidateChannelCache(channelId); for (let channelId in this.channelMessages) this.invalidateChannelCache(channelId);
@ -2535,7 +2552,7 @@ module.exports = class MessageLoggerV2 {
} }
this.saveDeletedMessage(deleted, this.deletedMessageRecord); this.saveDeletedMessage(deleted, this.deletedMessageRecord);
this.saveData(); this.saveData();
if (ZeresPluginLibrary.DiscordAPI.currentChannel && ZeresPluginLibrary.DiscordAPI.currentChannel.id === dispatch.channelId) ZeresPluginLibrary.DiscordModules.Dispatcher.dispatch({ type: 'MLV2_FORCE_UPDATE_MESSAGE', id: dispatch.id }); if (this.currentChannel() && this.currentChannel().id === dispatch.channelId) ZeresPluginLibrary.DiscordModules.Dispatcher.dispatch({ type: 'MLV2_FORCE_UPDATE_MESSAGE', id: dispatch.id });
} else if (dispatch.type === 'MESSAGE_UPDATE') { } else if (dispatch.type === 'MESSAGE_UPDATE') {
if (!dispatch.message.edited_timestamp) { if (!dispatch.message.edited_timestamp) {
let last = this.getCachedMessage(dispatch.message.id); let last = this.getCachedMessage(dispatch.message.id);
@ -2700,7 +2717,7 @@ module.exports = class MessageLoggerV2 {
this.saveDeletedMessage(deleted, this.deletedMessageRecord); this.saveDeletedMessage(deleted, this.deletedMessageRecord);
// if (this.settings.cacheAllImages) this.cacheImages(deleted); // if (this.settings.cacheAllImages) this.cacheImages(deleted);
if (!this.settings.showDeletedMessages) callDefault(...args); if (!this.settings.showDeletedMessages) callDefault(...args);
else if (ZeresPluginLibrary.DiscordAPI.currentChannel && ZeresPluginLibrary.DiscordAPI.currentChannel.id === dispatch.channelId) ZeresPluginLibrary.DiscordModules.Dispatcher.dispatch({ type: 'MLV2_FORCE_UPDATE_MESSAGE', id: dispatch.id }); else if (this.currentChannel() && this.currentChannel().id === dispatch.channelId) ZeresPluginLibrary.DiscordModules.Dispatcher.dispatch({ type: 'MLV2_FORCE_UPDATE_MESSAGE', id: dispatch.id });
this.saveData(); this.saveData();
} else if (dispatch.type == 'MESSAGE_DELETE_BULK') { } else if (dispatch.type == 'MESSAGE_DELETE_BULK') {
if (this.settings.showDeletedCount) { if (this.settings.showDeletedCount) {
@ -2717,7 +2734,7 @@ module.exports = class MessageLoggerV2 {
continue; continue;
} }
this.saveDeletedMessage(purged, this.purgedMessageRecord); this.saveDeletedMessage(purged, this.purgedMessageRecord);
if (ZeresPluginLibrary.DiscordAPI.currentChannel && ZeresPluginLibrary.DiscordAPI.currentChannel.id === dispatch.channelId) ZeresPluginLibrary.DiscordModules.Dispatcher.dispatch({ type: 'MLV2_FORCE_UPDATE_MESSAGE', id: purged.id }); if (this.currentChannel() && this.currentChannel().id === dispatch.channelId) ZeresPluginLibrary.DiscordModules.Dispatcher.dispatch({ type: 'MLV2_FORCE_UPDATE_MESSAGE', id: purged.id });
} }
if (failedMessage && this.aggresiveMessageCaching) if (failedMessage && this.aggresiveMessageCaching)