Reddit++

Множество улучшений для нового интерфейса reddit.com, таких как развернутые кнопки лент, увеличенный шрифт, увеличение изображений без редиректа и много другое...

< Обсуждения Reddit++

Отзыв: Нормальный — скрипт работает, но имеет существенные недостатки

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

lnm95Автор
§
Создано: 08.09.2024

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.

§
Создано: 16.09.2024
Отредактировано: 16.09.2024

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);
        }
    }
}

Ответить

Войдите, чтобы ответить.