paywallr/settings.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-04-02 19:20:12 +02:00
// ____
// ___ ___ ___ ___ _____ _/ / /___
// / _ \/ _ `/ // / |/|/ / _ `/ / / __/
// / .__/\_,_/\_, /|__,__/\_,_/_/_/_/
// /_/ /___/
//
// settings background script
// github.com/tobimori/paywallr
//
const changeListener = () => {
extapi.tabs.query({
active: true,
currentWindow: true
}, (tab) => {
extapi.browserAction.setBadgeBackgroundColor({ "color": "black" });
!isSite(tab[0].url) && extapi.browserAction.disable(tab[0].id);
isSite(tab[0].url) && isSiteEnabled(tab[0].url) ?
extapi.browserAction.setBadgeText({
"text": "ON", "tabId": tab[0].id
}) :
extapi.browserAction.setBadgeText({
"text": "OFF", "tabId": tab[0].id
});
}
)
};
extapi.tabs.onUpdated.addListener(changeListener());
extapi.tabs.Activated.addListener(changeListener());
extapi.browserAction.onClicked.addListener((tab) => {
2020-04-02 23:25:03 +02:00
// const url = shortUrl(tab.url)
2020-04-02 19:20:12 +02:00
isSite(tab.url) && extapi.storage.sync.set({
2020-04-02 23:25:03 +02:00
url: true
2020-04-02 19:20:12 +02:00
});
});