diff options
Diffstat (limited to 'recipes/pleroma/webview.js')
-rw-r--r-- | recipes/pleroma/webview.js | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/recipes/pleroma/webview.js b/recipes/pleroma/webview.js index d9fc9b1..07f2dc0 100644 --- a/recipes/pleroma/webview.js +++ b/recipes/pleroma/webview.js | |||
@@ -4,10 +4,10 @@ const titleRegex = /^\((\d+)\)/; | |||
4 | 4 | ||
5 | const getJson = async (relativeUri) => { | 5 | const getJson = async (relativeUri) => { |
6 | const req = await window.fetch(`${window.origin}${relativeUri}`, { | 6 | const req = await window.fetch(`${window.origin}${relativeUri}`, { |
7 | 'Accept': 'application/json' | 7 | Accept: 'application/json', |
8 | }); | 8 | }); |
9 | return req.json(); | 9 | return req.json(); |
10 | } | 10 | }; |
11 | 11 | ||
12 | const getInstanceConfig = async () => { | 12 | const getInstanceConfig = async () => { |
13 | const origin = window.origin; | 13 | const origin = window.origin; |
@@ -59,7 +59,7 @@ const unscalePixel = b => b / SCALE; | |||
59 | const blend = (bgValue, bgWeight, fgValue, fgWeight) => { | 59 | const blend = (bgValue, bgWeight, fgValue, fgWeight) => { |
60 | const sum = bgValue * bgWeight + fgValue * fgWeight; | 60 | const sum = bgValue * bgWeight + fgValue * fgWeight; |
61 | return clamp(sum / (bgWeight + fgWeight)); | 61 | return clamp(sum / (bgWeight + fgWeight)); |
62 | } | 62 | }; |
63 | 63 | ||
64 | class LogoUpdater { | 64 | class LogoUpdater { |
65 | constructor(img, mask) { | 65 | constructor(img, mask) { |
@@ -87,12 +87,10 @@ class LogoUpdater { | |||
87 | this._previousFg = fg; | 87 | this._previousFg = fg; |
88 | return true; | 88 | return true; |
89 | } | 89 | } |
90 | } else { | 90 | } else if (this._previousBg !== bg) { |
91 | if (this._previousBg !== bg) { | 91 | this._updateNoMask(bg); |
92 | this._updateNoMask(bg); | 92 | this._previousBg = bg; |
93 | this._previousBg = bg; | 93 | return true; |
94 | return true; | ||
95 | } | ||
96 | } | 94 | } |
97 | return false; | 95 | return false; |
98 | } | 96 | } |
@@ -133,7 +131,7 @@ class LogoUpdater { | |||
133 | this._ctx.fillStyle = str; | 131 | this._ctx.fillStyle = str; |
134 | this._ctx.fillRect(0, 0, 1, 1); | 132 | this._ctx.fillRect(0, 0, 1, 1); |
135 | return this._ctx.getImageData(0, 0, 1, 1).data; | 133 | return this._ctx.getImageData(0, 0, 1, 1).data; |
136 | }; | 134 | } |
137 | 135 | ||
138 | _drawImage() { | 136 | _drawImage() { |
139 | this._ctx.drawImage(this._img, this._dx, this._dy); | 137 | this._ctx.drawImage(this._img, this._dx, this._dy); |
@@ -141,7 +139,6 @@ class LogoUpdater { | |||
141 | } | 139 | } |
142 | 140 | ||
143 | module.exports = Ferdi => { | 141 | module.exports = Ferdi => { |
144 | |||
145 | const getMessages = () => { | 142 | const getMessages = () => { |
146 | let directCount = 0; | 143 | let directCount = 0; |
147 | const matchArr = document.title.match(titleRegex); | 144 | const matchArr = document.title.match(titleRegex); |
@@ -162,5 +159,5 @@ module.exports = Ferdi => { | |||
162 | }, (e) => { | 159 | }, (e) => { |
163 | console.log('Failed to load instance logo', e); | 160 | console.log('Failed to load instance logo', e); |
164 | Ferdi.loop(getMessages); | 161 | Ferdi.loop(getMessages); |
165 | }) | 162 | }); |
166 | }; | 163 | }; |