youtube icon indicating copy to clipboard operation
youtube copied to clipboard

Update functions.js

Open Durgesh4993 opened this issue 11 months ago • 4 comments

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:

  • The chrome.storage.sync API is used directly to synchronize extension settings with the user's Google Account, enabling automatic data synchronization across devices where the user is signed in.
  • The syncSettings function saves the entire extension storage data to the synced storage.
  • The pullSettings function retrieves all data from the synced storage and updates the extension's local storage with the synced data.

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

Durgesh4993 avatar Mar 03 '24 00:03 Durgesh4993