another attempt

This commit is contained in:
Zack Rauen 2018-07-19 10:00:24 -04:00
parent 1371a8916e
commit 48844445d6
2 changed files with 6 additions and 6 deletions

View File

@ -795,7 +795,7 @@ EmoteModule.prototype.init = async function () {
if (this.cancel1) this.cancel1();
if (this.cancel2) this.cancel2();
this.cancel1 = Utils.monkeyPatch(MessageComponent.prototype, "componentDidMount", {after: (data) => {
this.cancel1 = Utils.monkeyPatch(MessageComponent.prototype, "componentDidMount", {force: true, after: (data) => {
if (!settingsCookie["bda-es-7"] && !settingsCookie["bda-es-2"] && !settingsCookie["bda-es-1"]) return;
let message = BDV2.reactDom.findDOMNode(data.thisObject);
message = message.querySelector('.markup');
@ -803,7 +803,7 @@ EmoteModule.prototype.init = async function () {
this.injectEmote(message);
}});
this.cancel2 = Utils.monkeyPatch(MessageComponent.prototype, "componentDidUpdate", {after: (data) => {
this.cancel2 = Utils.monkeyPatch(MessageComponent.prototype, "componentDidUpdate", {force: true, after: (data) => {
if (!settingsCookie["bda-es-7"] && !settingsCookie["bda-es-2"] && !settingsCookie["bda-es-1"]) return;
let message = BDV2.reactDom.findDOMNode(data.thisObject);
message = message.querySelector('.markup');
@ -1430,11 +1430,11 @@ Utils.monkeyPatch = (what, methodName, options) => {
const {before, after, instead, once = false, silent = false, force = false} = options;
const displayName = options.displayName || what.displayName || what.name || what.constructor.displayName || what.constructor.name;
if (!silent) console.log('patch', methodName, 'of', displayName); // eslint-disable-line no-console
let origMethod = what[methodName];
if (!origMethod) {
if (force) origMethod = what[methodName] = () => {};
if (!what[methodName]) {
if (force) what[methodName] = function() {};
else return console.error(methodName, 'does not exist for', displayName); // eslint-disable-line no-console
}
const origMethod = what[methodName];
const cancel = () => {
if (!silent) console.log('unpatch', methodName, 'of', displayName); // eslint-disable-line no-console
what[methodName] = origMethod;

2
js/main.min.js vendored

File diff suppressed because one or more lines are too long