From 590846ca38539954e823f2ede3379a84c936804b Mon Sep 17 00:00:00 2001 From: Marcin Jakubowski Date: Tue, 19 Jul 2022 01:35:10 +0200 Subject: [PATCH] patch live version of the object as well --- extension.js | 16 ++++++++++------ metadata.json | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/extension.js b/extension.js index 944e925..9ab0810 100644 --- a/extension.js +++ b/extension.js @@ -34,10 +34,11 @@ let PADDING_VERTICAL = 0; let PADDING_HORIZONTAL = 0; let ALWAYS_MINIMIZE = 0; -function patcher(obj, method, original, patch) { +function patcher(obj, live, method, original, patch) { const body = eval(`${obj}.prototype.${method}.toString()`); const newBody = body.replace(original, patch).replace(method + "(", "function(") eval(`${obj}.prototype.${method} = ${newBody}`); + eval(`${live}.${method} = ${newBody}`); } const getMessageTraySize = () => ({ width, height } = Main.layoutManager.getWorkAreaForMonitor(global.display.get_current_monitor())); @@ -89,7 +90,6 @@ function calcHide(self) { y = getMessageTraySize().height break; } - return { x, y } } @@ -127,16 +127,19 @@ function calcStart(self) { const patches = [ { "obj": "MessageTray", "method": "_updateShowingNotification", + "live": "Main.messageTray", "original": 'y: 0', "patch": '...calcTarget(this)' }, { "obj": "MessageTray", "method": "_showNotification", + "live": "Main.messageTray", "original": 'this._bannerBin.y = -this._banner.height', "patch": 'calcStart(this)' }, { "obj": "MessageTray", "method": "_hideNotification", + "live": "Main.messageTray", "original": 'y: -this._bannerBin.height', "patch": '...calcHide(this)' } @@ -144,6 +147,7 @@ const patches = [ const always_minimize_patch = { obj: "MessageTray", + live: "Main.messageTray", method: "_updateShowingNotification", original: "this._expandBanner(true)", patch: "// always minimized setting enabled by notification-banner-reloaded ... this._expandBanner(true)", @@ -188,13 +192,13 @@ class Extension { BannerBin.set_x_align(x_align); BannerBin.set_y_align(y_align); this.restore(); - for (const { obj, method, original, patch } of patches) { - patcher(obj, method, original, patch) + for (const { obj, live, method, original, patch } of patches) { + patcher(obj, live, method, original, patch) } if (ALWAYS_MINIMIZE) { - const { obj, method, original, patch } = always_minimize_patch; - patcher(obj, method, original, patch); + const { obj, live, method, original, patch } = always_minimize_patch; + patcher(obj, live, method, original, patch); } } diff --git a/metadata.json b/metadata.json index 1fb990e..b585547 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "Notification Banner Reloaded", - "version": 5, + "version": 6, "_generated": "Generated by SweetTooth, do not edit", "description": "Configure notification banner position and animation to your liking", "uuid": "notification-banner-reloaded@marcinjakubowski.github.com",