ccd0 / 4chan-x

Adds various features to anonymous imageboards.
https://www.4chan-x.net/
Other
989 stars 135 forks source link

Update API type verification in userscript #3300

Open erosman opened 2 years ago

erosman commented 2 years ago

Ref: https://www.4chan-x.net/builds/4chan-X.user.js

FireMonkey supports booth GM_* & GM.* API, but favours async GM.* if a userscript supports both.

Therefore, in the 4chan-X.user.js, the sync GM_* support are removed, resulting in

// @grant        GM_addValueChangeListener
// @grant        GM.getValue
// @grant        GM.setValue
// @grant        GM.deleteValue
// @grant        GM.listValues
// @grant        GM.openInTab
// @grant        GM.xmlHttpRequest

Userscript checks for the type of API to use which is fine everywhere but on line 5550 it causes an error in FireMonkey.

Line 5550

if (typeof GM_addValueChangeListener !== "undefined" && GM_addValueChangeListener !== null) {
  $.setValue = GM_setValue;
  $.deleteValue = GM_deleteValue;
} 

image

tomato-paste commented 10 months ago

Reference: https://github.com/erosman/support/issues/507

In FireMonkey (4chan-X 1.14.22.4, Firefox 121, FM 2.72), the script can't use the BroadcastChannel API (simply doesn't exist); so the following check fails and the code fall-backs to the GM_* code: https://github.com/ccd0/4chan-x/blob/103c9849cc8aeba4b1521dad5176ac31d9ba69d3/src/platform/%24.coffee#L654-L656 We couldn't find why, help would be appreciated.

saxamaphone69 commented 9 months ago

Using blame reveals changes back in 2017 as for some potential reasons.