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

@ -2,24 +2,24 @@
/*@cc_on /*@cc_on
@if (@_jscript) @if (@_jscript)
// Offer to self-install for clueless users that try to run this directly. // Offer to self-install for clueless users that try to run this directly.
var shell = WScript.CreateObject('WScript.Shell'); var shell = WScript.CreateObject('WScript.Shell');
var fs = new ActiveXObject('Scripting.FileSystemObject'); var fs = new ActiveXObject('Scripting.FileSystemObject');
var pathPlugins = shell.ExpandEnvironmentStrings('%APPDATA%\\BetterDiscord\\plugins'); var pathPlugins = shell.ExpandEnvironmentStrings('%APPDATA%\\BetterDiscord\\plugins');
var pathSelf = WScript.ScriptFullName; var pathSelf = WScript.ScriptFullName;
// Put the user at ease by addressing them in the first person // Put the user at ease by addressing them in the first person
shell.Popup('It looks like you\'ve mistakenly tried to run me directly. \n(Don\'t do that!)', 0, 'I\'m a plugin for BetterDiscord', 0x30); shell.Popup('It looks like you\'ve mistakenly tried to run me directly. \n(Don\'t do that!)', 0, 'I\'m a plugin for BetterDiscord', 0x30);
if (fs.GetParentFolderName(pathSelf) === fs.GetAbsolutePathName(pathPlugins)) { if (fs.GetParentFolderName(pathSelf) === fs.GetAbsolutePathName(pathPlugins)) {
shell.Popup('I\'m in the correct folder already.\nJust go to settings, plugins and enable me.', 0, 'I\'m already installed', 0x40); shell.Popup('I\'m in the correct folder already.\nJust go to settings, plugins and enable me.', 0, 'I\'m already installed', 0x40);
} else if (!fs.FolderExists(pathPlugins)) { } else if (!fs.FolderExists(pathPlugins)) {
shell.Popup('I can\'t find the BetterDiscord plugins folder.\nAre you sure it\'s even installed?', 0, 'Can\'t install myself', 0x10); shell.Popup('I can\'t find the BetterDiscord plugins folder.\nAre you sure it\'s even installed?', 0, 'Can\'t install myself', 0x10);
} else if (shell.Popup('Should I copy myself to BetterDiscord\'s plugins folder for you?', 0, 'Do you need some help?', 0x34) === 6) { } else if (shell.Popup('Should I copy myself to BetterDiscord\'s plugins folder for you?', 0, 'Do you need some help?', 0x34) === 6) {
fs.CopyFile(pathSelf, fs.BuildPath(pathPlugins, fs.GetFileName(pathSelf)), true); fs.CopyFile(pathSelf, fs.BuildPath(pathPlugins, fs.GetFileName(pathSelf)), true);
// Show the user where to put plugins in the future // Show the user where to put plugins in the future
shell.Exec('explorer ' + pathPlugins); shell.Exec('explorer ' + pathPlugins);
shell.Popup('I\'m installed!\nJust go to settings, plugins and enable me!', 0, 'Successfully installed', 0x40); shell.Popup('I\'m installed!\nJust go to settings, plugins and enable me!', 0, 'Successfully installed', 0x40);
} }
WScript.Quit(); WScript.Quit();
@else@*/ @else@*/
@ -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;
} }
@ -1133,29 +1135,29 @@ module.exports = (() => {
[ [
this.props.__BIV_settings.ui.navButtons || this.props.__BIV_settings.behavior.debug this.props.__BIV_settings.ui.navButtons || this.props.__BIV_settings.behavior.debug
? [ ? [
React.createElement( React.createElement(
Clickable, Clickable,
{ {
className: XenoLib.joinClassNames('BIV-left', { 'BIV-disabled': currentImage === this._maxImages && (this._searchCache.noBefore || this.state.rateLimited), 'BIV-inactive': this.state.controlsInactive, 'BIV-hidden': !this.state.controlsVisible }), className: XenoLib.joinClassNames('BIV-left', { 'BIV-disabled': currentImage === this._maxImages && (this._searchCache.noBefore || this.state.rateLimited), 'BIV-inactive': this.state.controlsInactive, 'BIV-hidden': !this.state.controlsVisible }),
onClick: this.handlePrevious, onClick: this.handlePrevious,
onContextMenu: this.handleFastJumpLeft, onContextMenu: this.handleFastJumpLeft,
onMouseEnter: this.handleMouseEnterLeft, onMouseEnter: this.handleMouseEnterLeft,
onMouseLeave: this.handleMouseLeave onMouseLeave: this.handleMouseLeave
}, },
React.createElement(LeftCaretIcon) React.createElement(LeftCaretIcon)
), ),
React.createElement( React.createElement(
Clickable, Clickable,
{ {
className: XenoLib.joinClassNames('BIV-right', { 'BIV-disabled': currentImage === 1, 'BIV-inactive': this.state.controlsInactive, 'BIV-hidden': !this.state.controlsVisible }), className: XenoLib.joinClassNames('BIV-right', { 'BIV-disabled': currentImage === 1, 'BIV-inactive': this.state.controlsInactive, 'BIV-hidden': !this.state.controlsVisible }),
onClick: this.handleNext, onClick: this.handleNext,
onContextMenu: this.handleFastJumpRight, onContextMenu: this.handleFastJumpRight,
onMouseEnter: this.handleMouseEnterRight, onMouseEnter: this.handleMouseEnterRight,
onMouseLeave: this.handleMouseLeave onMouseLeave: this.handleMouseLeave
}, },
React.createElement(RightCaretIcon) React.createElement(RightCaretIcon)
) )
] ]
: null, : null,
React.createElement( React.createElement(
'div', 'div',
@ -1164,25 +1166,25 @@ module.exports = (() => {
}, },
this.props.__BIV_settings.ui.imageIndex || this.props.__BIV_settings.behavior.debug this.props.__BIV_settings.ui.imageIndex || this.props.__BIV_settings.behavior.debug
? React.createElement( ? React.createElement(
TextElement, TextElement,
{ {
className: 'BIV-text-bold' className: 'BIV-text-bold'
}, },
'Image ', 'Image ',
currentImage, currentImage,
' of ', ' of ',
this._maxImages, this._maxImages,
this._searchCache._totalResults || this.props.__BIV_settings.behavior.debug this._searchCache._totalResults || this.props.__BIV_settings.behavior.debug
? React.createElement( ? React.createElement(
Tooltip, Tooltip,
{ {
text: `Estimated ${this._maxImages + this._searchCache._totalResults} images in current channel`, text: `Estimated ${this._maxImages + this._searchCache._totalResults} images in current channel`,
position: 'top' position: 'top'
}, },
e => React.createElement('span', e, ' (~', this._maxImages + this._searchCache._totalResults, ')') e => React.createElement('span', e, ' (~', this._maxImages + this._searchCache._totalResults, ')')
) )
: undefined : undefined
) )
: null, : null,
React.createElement( React.createElement(
'div', 'div',
@ -1204,8 +1206,8 @@ module.exports = (() => {
style: style:
iMember && iMember.colorString iMember && iMember.colorString
? { ? {
color: iMember.colorString color: iMember.colorString
} }
: null, : null,
onClick: () => { onClick: () => {
this.props.onClose(); this.props.onClose();
@ -1218,78 +1220,63 @@ module.exports = (() => {
timestamp: DiscordModules.Moment(message.timestamp) timestamp: DiscordModules.Moment(message.timestamp)
}), }),
(this.props.__BIV_settings.behavior.debug || this._searchCache.noBefore) && (this.props.__BIV_settings.behavior.debug || this._searchCache.noBefore) &&
React.createElement(
'div',
{
className: XenoLib.joinClassNames('BIV-requesting', TextElement.Colors.ERROR)
},
React.createElement( React.createElement(
'div', Tooltip,
{ {
className: XenoLib.joinClassNames('BIV-requesting', TextElement.Colors.ERROR) text: 'You have reached the start of the channel'
}, },
React.createElement( e => React.createElement(LeftCaretIcon, e)
Tooltip, )
{ ),
text: 'You have reached the start of the channel'
},
e => React.createElement(LeftCaretIcon, e)
)
),
(this.props.__BIV_settings.behavior.debug || (this.state.isNearingEdge && !this.props.__BIV_settings.behavior.searchAPI)) && (this.props.__BIV_settings.behavior.debug || (this.state.isNearingEdge && !this.props.__BIV_settings.behavior.searchAPI)) &&
React.createElement(
'div',
{
className: XenoLib.joinClassNames('BIV-requesting', TextElement.Colors.STATUS_YELLOW)
},
React.createElement( React.createElement(
'div', Tooltip,
{ {
className: XenoLib.joinClassNames('BIV-requesting', TextElement.Colors.STATUS_YELLOW) text: 'You are nearing the edge of available images. If you want more, enable search API.'
}, },
React.createElement( e => React.createElement(WarningTriangleIcon, e)
Tooltip, )
{ ),
text: 'You are nearing the edge of available images. If you want more, enable search API.'
},
e => React.createElement(WarningTriangleIcon, e)
)
),
(this.props.__BIV_settings.behavior.debug || (this.state.requesting && !this.state.unknownError)) && (this.props.__BIV_settings.behavior.debug || (this.state.requesting && !this.state.unknownError)) &&
React.createElement(
'div',
{
className: 'BIV-requesting'
},
React.createElement( React.createElement(
'div', Tooltip,
{ {
className: 'BIV-requesting' text: 'Requesting more...'
}, },
React.createElement( e => React.createElement(UpdateAvailableIcon, e)
Tooltip, )
{ ),
text: 'Requesting more...'
},
e => React.createElement(UpdateAvailableIcon, e)
)
),
(this.props.__BIV_settings.behavior.debug || this.state.indexing) && (this.props.__BIV_settings.behavior.debug || this.state.indexing) &&
React.createElement(
'div',
{
className: 'BIV-requesting'
},
React.createElement( React.createElement(
'div', Tooltip,
{ {
className: 'BIV-requesting' text: 'Indexing channel...'
}, },
React.createElement( e => React.createElement(SearchIcon, e)
Tooltip, )
{ ),
text: 'Indexing channel...'
},
e => React.createElement(SearchIcon, e)
)
),
this.props.__BIV_settings.behavior.debug || this.state.localRateLimited || this.state.rateLimited this.props.__BIV_settings.behavior.debug || this.state.localRateLimited || this.state.rateLimited
? React.createElement( ? React.createElement(
'div',
{
className: XenoLib.joinClassNames('BIV-requesting', TextElement.Colors.ERROR)
},
React.createElement(
Tooltip,
{
text: 'You have been rate limited, please wait'
},
e => React.createElement(TimerIcon, e)
)
)
: undefined,
(this.props.__BIV_settings.behavior.debug || this._followNew) &&
React.createElement(
'div', 'div',
{ {
className: XenoLib.joinClassNames('BIV-requesting', TextElement.Colors.ERROR) className: XenoLib.joinClassNames('BIV-requesting', TextElement.Colors.ERROR)
@ -1297,25 +1284,40 @@ module.exports = (() => {
React.createElement( React.createElement(
Tooltip, Tooltip,
{ {
text: 'You have reached the end of the channel and are listening for new images' text: 'You have been rate limited, please wait'
}, },
e => React.createElement(RightCaretIcon, e) e => React.createElement(TimerIcon, e)
)
),
(this.props.__BIV_settings.behavior.debug || this.state.unknownError) &&
React.createElement(
'div',
{
className: XenoLib.joinClassNames('BIV-requesting', TextElement.Colors.ERROR)
},
React.createElement(
Tooltip,
{
text: 'Unknown error occured'
},
e => React.createElement(ClearIcon, e)
) )
) )
: undefined,
(this.props.__BIV_settings.behavior.debug || this._followNew) &&
React.createElement(
'div',
{
className: XenoLib.joinClassNames('BIV-requesting', TextElement.Colors.ERROR)
},
React.createElement(
Tooltip,
{
text: 'You have reached the end of the channel and are listening for new images'
},
e => React.createElement(RightCaretIcon, e)
)
),
(this.props.__BIV_settings.behavior.debug || this.state.unknownError) &&
React.createElement(
'div',
{
className: XenoLib.joinClassNames('BIV-requesting', TextElement.Colors.ERROR)
},
React.createElement(
Tooltip,
{
text: 'Unknown error occured'
},
e => React.createElement(ClearIcon, e)
)
)
) )
) )
) )
@ -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;
@ -2015,132 +2029,132 @@ module.exports = (() => {
return !global.ZeresPluginLibrary || !global.XenoLib || ZeresPluginLibraryOutdated || XenoLibOutdated return !global.ZeresPluginLibrary || !global.XenoLib || ZeresPluginLibraryOutdated || XenoLibOutdated
? class { ? class {
constructor() { constructor() {
this._XL_PLUGIN = true; this._XL_PLUGIN = true;
this.start = this.load = this.handleMissingLib; this.start = this.load = this.handleMissingLib;
}
getName() {
return this.name.replace(/\s+/g, '');
}
getAuthor() {
return this.author;
}
getVersion() {
return this.version;
}
getDescription() {
return this.description + ' You are missing libraries for this plugin, please enable the plugin and click Download Now.';
}
start() {}
stop() {}
handleMissingLib() {
const a = BdApi.findModuleByProps('openModal', 'hasModalOpen');
if (a && a.hasModalOpen(`${this.name}_DEP_MODAL`)) return;
const b = !global.XenoLib,
c = !global.ZeresPluginLibrary,
d = (b && c) || ((b || c) && (XenoLibOutdated || ZeresPluginLibraryOutdated)),
e = (() => {
let a = '';
return b || c ? (a += `Missing${XenoLibOutdated || ZeresPluginLibraryOutdated ? ' and outdated' : ''} `) : (XenoLibOutdated || ZeresPluginLibraryOutdated) && (a += `Outdated `), (a += `${d ? 'Libraries' : 'Library'} `), a;
})(),
f = (() => {
let a = `The ${d ? 'libraries' : 'library'} `;
return b || XenoLibOutdated ? ((a += 'XenoLib '), (c || ZeresPluginLibraryOutdated) && (a += 'and ZeresPluginLibrary ')) : (c || ZeresPluginLibraryOutdated) && (a += 'ZeresPluginLibrary '), (a += `required for ${this.name} ${d ? 'are' : 'is'} ${b || c ? 'missing' : ''}${XenoLibOutdated || ZeresPluginLibraryOutdated ? (b || c ? ' and/or outdated' : 'outdated') : ''}.`), a;
})(),
g = BdApi.findModuleByDisplayName('Text'),
h = BdApi.findModuleByDisplayName('ConfirmModal'),
i = () => BdApi.alert(e, BdApi.React.createElement('span', {}, BdApi.React.createElement('div', {}, f), `Due to a slight mishap however, you'll have to download the libraries yourself. This is not intentional, something went wrong, errors are in console.`, c || ZeresPluginLibraryOutdated ? BdApi.React.createElement('div', {}, BdApi.React.createElement('a', { href: 'https://betterdiscord.net/ghdl?id=2252', target: '_blank' }, 'Click here to download ZeresPluginLibrary')) : null, b || XenoLibOutdated ? BdApi.React.createElement('div', {}, BdApi.React.createElement('a', { href: 'https://betterdiscord.net/ghdl?id=3169', target: '_blank' }, 'Click here to download XenoLib')) : null));
if (!a || !h || !g) return console.error(`Missing components:${(a ? '' : ' ModalStack') + (h ? '' : ' ConfirmationModalComponent') + (g ? '' : 'TextElement')}`), i();
class j extends BdApi.React.PureComponent {
constructor(a) {
super(a), (this.state = { hasError: !1 }), (this.componentDidCatch = a => (console.error(`Error in ${this.props.label}, screenshot or copy paste the error above to Lighty for help.`), this.setState({ hasError: !0 }), 'function' == typeof this.props.onError && this.props.onError(a))), (this.render = () => (this.state.hasError ? null : this.props.children));
}
}
let k = !1,
l = !1;
const m = a.openModal(
b => {
if (l) return null;
try {
return BdApi.React.createElement(
j,
{ label: 'missing dependency modal', onError: () => (a.closeModal(m), i()) },
BdApi.React.createElement(
h,
Object.assign(
{
header: e,
children: BdApi.React.createElement(g, { size: g.Sizes.SIZE_16, children: [`${f} Please click Download Now to download ${d ? 'them' : 'it'}.`] }),
red: !1,
confirmText: 'Download Now',
cancelText: 'Cancel',
onCancel: b.onClose,
onConfirm: () => {
if (k) return;
k = !0;
const b = require('request'),
c = require('fs'),
d = require('path'),
e = BdApi.Plugins && BdApi.Plugins.folder ? BdApi.Plugins.folder : window.ContentManager.pluginsFolder,
f = () => {
(global.XenoLib && !XenoLibOutdated) ||
b('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (b, f, g) => {
try {
if (b || 200 !== f.statusCode) return a.closeModal(m), i();
c.writeFile(d.join(e, '1XenoLib.plugin.js'), g, () => {});
} catch (b) {
console.error('Fatal error downloading XenoLib', b), a.closeModal(m), i();
}
});
};
!global.ZeresPluginLibrary || ZeresPluginLibraryOutdated
? b('https://raw.githubusercontent.com/rauenzi/BDPluginLibrary/master/release/0PluginLibrary.plugin.js', (b, g, h) => {
try {
if (b || 200 !== g.statusCode) return a.closeModal(m), i();
c.writeFile(d.join(e, '0PluginLibrary.plugin.js'), h, () => {}), f();
} catch (b) {
console.error('Fatal error downloading ZeresPluginLibrary', b), a.closeModal(m), i();
}
})
: f();
}
},
b,
{ onClose: () => {} }
)
)
);
} catch (b) {
return console.error('There has been an error constructing the modal', b), (l = !0), a.closeModal(m), i(), null;
}
},
{ modalKey: `${this.name}_DEP_MODAL` }
);
}
get [Symbol.toStringTag]() {
return 'Plugin';
}
get name() {
return config.info.name;
}
get short() {
let string = '';
for (let i = 0, len = config.info.name.length; i < len; i++) {
const char = config.info.name[i];
if (char === char.toUpperCase()) string += char;
}
return string;
}
get author() {
return config.info.authors.map(author => author.name).join(', ');
}
get version() {
return config.info.version;
}
get description() {
return config.info.description;
}
} }
getName() {
return this.name.replace(/\s+/g, '');
}
getAuthor() {
return this.author;
}
getVersion() {
return this.version;
}
getDescription() {
return this.description + ' You are missing libraries for this plugin, please enable the plugin and click Download Now.';
}
start() { }
stop() { }
handleMissingLib() {
const a = BdApi.findModuleByProps('openModal', 'hasModalOpen');
if (a && a.hasModalOpen(`${this.name}_DEP_MODAL`)) return;
const b = !global.XenoLib,
c = !global.ZeresPluginLibrary,
d = (b && c) || ((b || c) && (XenoLibOutdated || ZeresPluginLibraryOutdated)),
e = (() => {
let a = '';
return b || c ? (a += `Missing${XenoLibOutdated || ZeresPluginLibraryOutdated ? ' and outdated' : ''} `) : (XenoLibOutdated || ZeresPluginLibraryOutdated) && (a += `Outdated `), (a += `${d ? 'Libraries' : 'Library'} `), a;
})(),
f = (() => {
let a = `The ${d ? 'libraries' : 'library'} `;
return b || XenoLibOutdated ? ((a += 'XenoLib '), (c || ZeresPluginLibraryOutdated) && (a += 'and ZeresPluginLibrary ')) : (c || ZeresPluginLibraryOutdated) && (a += 'ZeresPluginLibrary '), (a += `required for ${this.name} ${d ? 'are' : 'is'} ${b || c ? 'missing' : ''}${XenoLibOutdated || ZeresPluginLibraryOutdated ? (b || c ? ' and/or outdated' : 'outdated') : ''}.`), a;
})(),
g = BdApi.findModuleByDisplayName('Text'),
h = BdApi.findModuleByDisplayName('ConfirmModal'),
i = () => BdApi.alert(e, BdApi.React.createElement('span', {}, BdApi.React.createElement('div', {}, f), `Due to a slight mishap however, you'll have to download the libraries yourself. This is not intentional, something went wrong, errors are in console.`, c || ZeresPluginLibraryOutdated ? BdApi.React.createElement('div', {}, BdApi.React.createElement('a', { href: 'https://betterdiscord.net/ghdl?id=2252', target: '_blank' }, 'Click here to download ZeresPluginLibrary')) : null, b || XenoLibOutdated ? BdApi.React.createElement('div', {}, BdApi.React.createElement('a', { href: 'https://betterdiscord.net/ghdl?id=3169', target: '_blank' }, 'Click here to download XenoLib')) : null));
if (!a || !h || !g) return console.error(`Missing components:${(a ? '' : ' ModalStack') + (h ? '' : ' ConfirmationModalComponent') + (g ? '' : 'TextElement')}`), i();
class j extends BdApi.React.PureComponent {
constructor(a) {
super(a), (this.state = { hasError: !1 }), (this.componentDidCatch = a => (console.error(`Error in ${this.props.label}, screenshot or copy paste the error above to Lighty for help.`), this.setState({ hasError: !0 }), 'function' == typeof this.props.onError && this.props.onError(a))), (this.render = () => (this.state.hasError ? null : this.props.children));
}
}
let k = !1,
l = !1;
const m = a.openModal(
b => {
if (l) return null;
try {
return BdApi.React.createElement(
j,
{ label: 'missing dependency modal', onError: () => (a.closeModal(m), i()) },
BdApi.React.createElement(
h,
Object.assign(
{
header: e,
children: BdApi.React.createElement(g, { size: g.Sizes.SIZE_16, children: [`${f} Please click Download Now to download ${d ? 'them' : 'it'}.`] }),
red: !1,
confirmText: 'Download Now',
cancelText: 'Cancel',
onCancel: b.onClose,
onConfirm: () => {
if (k) return;
k = !0;
const b = require('request'),
c = require('fs'),
d = require('path'),
e = BdApi.Plugins && BdApi.Plugins.folder ? BdApi.Plugins.folder : window.ContentManager.pluginsFolder,
f = () => {
(global.XenoLib && !XenoLibOutdated) ||
b('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (b, f, g) => {
try {
if (b || 200 !== f.statusCode) return a.closeModal(m), i();
c.writeFile(d.join(e, '1XenoLib.plugin.js'), g, () => { });
} catch (b) {
console.error('Fatal error downloading XenoLib', b), a.closeModal(m), i();
}
});
};
!global.ZeresPluginLibrary || ZeresPluginLibraryOutdated
? b('https://raw.githubusercontent.com/rauenzi/BDPluginLibrary/master/release/0PluginLibrary.plugin.js', (b, g, h) => {
try {
if (b || 200 !== g.statusCode) return a.closeModal(m), i();
c.writeFile(d.join(e, '0PluginLibrary.plugin.js'), h, () => { }), f();
} catch (b) {
console.error('Fatal error downloading ZeresPluginLibrary', b), a.closeModal(m), i();
}
})
: f();
}
},
b,
{ onClose: () => { } }
)
)
);
} catch (b) {
return console.error('There has been an error constructing the modal', b), (l = !0), a.closeModal(m), i(), null;
}
},
{ modalKey: `${this.name}_DEP_MODAL` }
);
}
get [Symbol.toStringTag]() {
return 'Plugin';
}
get name() {
return config.info.name;
}
get short() {
let string = '';
for (let i = 0, len = config.info.name.length; i < len; i++) {
const char = config.info.name[i];
if (char === char.toUpperCase()) string += char;
}
return string;
}
get author() {
return config.info.authors.map(author => author.name).join(', ');
}
get version() {
return config.info.version;
}
get description() {
return config.info.description;
}
}
: buildPlugin(global.ZeresPluginLibrary.buildPlugin(config)); : buildPlugin(global.ZeresPluginLibrary.buildPlugin(config));
})(); })();

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
@ -61,7 +64,7 @@
### 1.2.0 ### 1.2.0
- Image previews will take up as much space as possible, larger images will be easier to view. - Image previews will take up as much space as possible, larger images will be easier to view.
- Image pixel will always be the same size as a physical pixel, this means all images will look sharp no matter what scaling your Discord (and system) is set to. Unless the image has been downscaled. - Image pixel will always be the same size as a physical pixel, this means all images will look sharp no matter what scaling your Discord (and system) is set to. Unless the image has been downscaled.
- Added a way to load the images at full resolution instead of downscaled. - Added a way to load the images at full resolution instead of downscaled.
**Pro tip**: don't fucking enable this, you *WILL NOT* notice a god damn difference. You can also force it to load the full res by *CTRL + CLICK*ing the preview. When it's loading the full res image, the first resolution at bottom right will turn red. **Pro tip**: don't fucking enable this, you *WILL NOT* notice a god damn difference. You can also force it to load the full res by *CTRL + CLICK*ing the preview. When it's loading the full res image, the first resolution at bottom right will turn red.
### 1.1.3 ### 1.1.3

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)