mirror of
https://github.com/lawrencehook/remove-youtube-suggestions.git
synced 2026-07-25 06:54:31 +00:00
34 lines
1.5 KiB
JavaScript
34 lines
1.5 KiB
JavaScript
const HTML = document.documentElement;
|
|
const SETTINGS_LIST = {
|
|
"global_enable": { defaultValue: true, eventType: 'click' },
|
|
"remove_homepage": { defaultValue: true, eventType: 'change' },
|
|
"remove_sidebar": { defaultValue: true, eventType: 'change' },
|
|
"remove_end_of_video": { defaultValue: true, eventType: 'change' },
|
|
"remove_info_cards": { defaultValue: false, eventType: 'change' },
|
|
"remove_home_link": { defaultValue: false, eventType: 'change' },
|
|
"remove_logo_link": { defaultValue: false, eventType: 'change' },
|
|
"remove_explore_link": { defaultValue: false, eventType: 'change' },
|
|
"remove_comments": { defaultValue: false, eventType: 'change' },
|
|
"remove_chat": { defaultValue: false, eventType: 'change' },
|
|
"redirect_off": { defaultValue: true, eventType: 'change' },
|
|
"redirect_to_subs": { defaultValue: false, eventType: 'change' },
|
|
"redirect_to_wl": { defaultValue: false, eventType: 'change' },
|
|
};
|
|
|
|
// Initialize HTML attributes with local settings, or default.
|
|
try {
|
|
browser.storage.local.get(localSettings => {
|
|
Object.entries(SETTINGS_LIST).forEach(([key, { defaultValue }]) => {
|
|
HTML.setAttribute(key, localSettings[key] ?? defaultValue);
|
|
});
|
|
});
|
|
} catch (e) {
|
|
console.log(e);
|
|
}
|
|
|
|
// Update HTML attributes in real time.
|
|
// receive messages from options.js
|
|
browser.runtime.onMessage.addListener((data, sender) => {
|
|
data.forEach(({ key, value }) => HTML.setAttribute(key, value));
|
|
});
|