Reddit++

A lot of enhancements for new design of reddit.com like unwrapped feed buttons, bigger fonts, view images without redirect and many more...

< 脚本Reddit++的反馈

评价:一般 - 脚本能用,但还有一些问题

§
发表于:2024-09-07

Works beautifully with Tempermonkey in Chrome/Firefox, but doesn't work in Safari with Userscripts. Please consider Userscripts for Mac.

lnm95作者
§
发表于:2024-09-08

As I see safary uses custom GM, so it may be point of the trouble. But I haven't a mac device to debug it. So I doubt to making some fixes without understanding that it's actually fix the trouble.

§
发表于:2024-09-16
编辑于:2024-09-16

I tried to tinker around with this and got to the point that I know the problem is that userscripts doesn't define "GM_getValue" or any of the "GM_" functions (Only GM_getValue and GM_setValue are used in RedditPlusPlus) but they rely on GM.getValue and GM.setValue instead. And the catch is that they are async functions, I started writing a wrapper for the storage but this ended up requiring changes in A LOT of places. I will create a draft PR later but basically this should be the starting point to support both TM and GM:

export class GMStorage {
    getValue(key: string, defaultValue: any) {
        if (typeof GM_getValue === 'function') {
            return Promise.resolve(GM_getValue(key, defaultValue));
        } else {
            return GM.getValue(key, defaultValue);
        }
    }

    setValue(key: string, value: any) {
        if (typeof GM_setValue === 'function') {
            return Promise.resolve(GM_setValue(key, value));
        } else {
            return GM.setValue(key, value);
        }
    }
}

发表回复

登录以发表回复。