patch live version of the object as well
This commit is contained in:
+10
-6
@@ -34,10 +34,11 @@ let PADDING_VERTICAL = 0;
|
|||||||
let PADDING_HORIZONTAL = 0;
|
let PADDING_HORIZONTAL = 0;
|
||||||
let ALWAYS_MINIMIZE = 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 body = eval(`${obj}.prototype.${method}.toString()`);
|
||||||
const newBody = body.replace(original, patch).replace(method + "(", "function(")
|
const newBody = body.replace(original, patch).replace(method + "(", "function(")
|
||||||
eval(`${obj}.prototype.${method} = ${newBody}`);
|
eval(`${obj}.prototype.${method} = ${newBody}`);
|
||||||
|
eval(`${live}.${method} = ${newBody}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const getMessageTraySize = () => ({ width, height } = Main.layoutManager.getWorkAreaForMonitor(global.display.get_current_monitor()));
|
const getMessageTraySize = () => ({ width, height } = Main.layoutManager.getWorkAreaForMonitor(global.display.get_current_monitor()));
|
||||||
@@ -89,7 +90,6 @@ function calcHide(self) {
|
|||||||
y = getMessageTraySize().height
|
y = getMessageTraySize().height
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { x, y }
|
return { x, y }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,16 +127,19 @@ function calcStart(self) {
|
|||||||
const patches = [
|
const patches = [
|
||||||
{
|
{
|
||||||
"obj": "MessageTray", "method": "_updateShowingNotification",
|
"obj": "MessageTray", "method": "_updateShowingNotification",
|
||||||
|
"live": "Main.messageTray",
|
||||||
"original": 'y: 0',
|
"original": 'y: 0',
|
||||||
"patch": '...calcTarget(this)'
|
"patch": '...calcTarget(this)'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"obj": "MessageTray", "method": "_showNotification",
|
"obj": "MessageTray", "method": "_showNotification",
|
||||||
|
"live": "Main.messageTray",
|
||||||
"original": 'this._bannerBin.y = -this._banner.height',
|
"original": 'this._bannerBin.y = -this._banner.height',
|
||||||
"patch": 'calcStart(this)'
|
"patch": 'calcStart(this)'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"obj": "MessageTray", "method": "_hideNotification",
|
"obj": "MessageTray", "method": "_hideNotification",
|
||||||
|
"live": "Main.messageTray",
|
||||||
"original": 'y: -this._bannerBin.height',
|
"original": 'y: -this._bannerBin.height',
|
||||||
"patch": '...calcHide(this)'
|
"patch": '...calcHide(this)'
|
||||||
}
|
}
|
||||||
@@ -144,6 +147,7 @@ const patches = [
|
|||||||
|
|
||||||
const always_minimize_patch = {
|
const always_minimize_patch = {
|
||||||
obj: "MessageTray",
|
obj: "MessageTray",
|
||||||
|
live: "Main.messageTray",
|
||||||
method: "_updateShowingNotification",
|
method: "_updateShowingNotification",
|
||||||
original: "this._expandBanner(true)",
|
original: "this._expandBanner(true)",
|
||||||
patch: "// always minimized setting enabled by notification-banner-reloaded ... 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_x_align(x_align);
|
||||||
BannerBin.set_y_align(y_align);
|
BannerBin.set_y_align(y_align);
|
||||||
this.restore();
|
this.restore();
|
||||||
for (const { obj, method, original, patch } of patches) {
|
for (const { obj, live, method, original, patch } of patches) {
|
||||||
patcher(obj, method, original, patch)
|
patcher(obj, live, method, original, patch)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ALWAYS_MINIMIZE) {
|
if (ALWAYS_MINIMIZE) {
|
||||||
const { obj, method, original, patch } = always_minimize_patch;
|
const { obj, live, method, original, patch } = always_minimize_patch;
|
||||||
patcher(obj, method, original, patch);
|
patcher(obj, live, method, original, patch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Notification Banner Reloaded",
|
"name": "Notification Banner Reloaded",
|
||||||
"version": 5,
|
"version": 6,
|
||||||
"_generated": "Generated by SweetTooth, do not edit",
|
"_generated": "Generated by SweetTooth, do not edit",
|
||||||
"description": "Configure notification banner position and animation to your liking",
|
"description": "Configure notification banner position and animation to your liking",
|
||||||
"uuid": "notification-banner-reloaded@marcinjakubowski.github.com",
|
"uuid": "notification-banner-reloaded@marcinjakubowski.github.com",
|
||||||
|
|||||||
Reference in New Issue
Block a user