code-charity / youtube

[top~1 open YouTube & Video browser-extension] - Enrich your experience & choice! 🧰180+ options & clever features 📌set+forget📌Longest-standing(been tough). Please join🧩us👨‍👩‍👧‍👧 ..⋮ {playback|content discovery|player|extra buttons|distractions|related videos|shorts|ads|quality|codec|full tab|full screen}
http://improvedtube.com
Other
3.48k stars 526 forks source link

Update functions.js #2056

Open Durgesh4993 opened 7 months ago

Durgesh4993 commented 7 months ago

Description:

Using this alternative approach simplifies the code by leveraging the built-in capabilities of the browser's storage synchronization mechanism, eliminating the need for custom export/import logic. It also ensures that the extension's settings are automatically synchronized across the user's devices without requiring explicit user actions for exporting/importing data.

In this alternative approach:

Code Changes:

var attributes = {
        theme: true,
        improvedtube_home: true,
        title_version: true,
        it_general: true,
        it_appearance: true,
        it_themes: true,
        it_player: true,
        it_playlist: true,
        it_channel: true,
        it_shortcuts: true,
        it_blocklist: true,
        it_analyzer: true,
        layer_animation_scale: false
    };

    for (var attribute in attributes) {
        var value = satus.storage.get(attribute);

        if (attribute === 'improvedtube_home') {
            attribute = 'home-style';
        }

        if (satus.isset(value)) {
            extension.skeleton.rendered.setAttribute(attribute.replace('it_', '').replace(/_/g, '-'), value);
        }
    }
raszpl commented 7 months ago

Wait a minute, not everyone uses chrome, and not everyone uses sync.

chrome.storage.sync.set

While this addition might be beneficial to those that do, it shouldnt remove settings raw file import/export like your pull request does.

timtoo commented 7 months ago

Wait a minute, not everyone uses chrome, and not everyone uses sync.

Firefox implements the storage.sync api, though I don't know the details of how it works if you don't have sync enabled.

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/sync

ImprovedTube commented 7 months ago

hi and thanks! @Durgesh4993 @raszpl @timtoo

raszpl commented 7 months ago

Hah I didnt even notice sync was already supported, so this patch just deletes manual file settings import/export while breaking sync. Weird.