Просмотр исходного кода

Refactored contentScript.js

master
Said Achmiz 6 лет назад
Родитель
Сommit
054b06a4cf
1 измененных файлов: 27 добавлений и 11 удалений
  1. 27
    11
      contentScript.js

+ 27
- 11
contentScript.js Просмотреть файл

window.onload = () => {
chrome.storage.sync.get([ "matchingPatterns", "exclusionPatterns", "mode" ],
(result) => {
killStickyIfMatch(result);
});
};

function killStickyIfMatch(result) {
if (typeof result.matchingPatterns == "undefined") return;
/***********/
/* HELPERS */
/***********/


function checkForShouldKillSticky(result) {
var shouldKillSticky = false; var shouldKillSticky = false;
let matchingPatterns = result.mode == "whitelist" ? let matchingPatterns = result.mode == "whitelist" ?
[ ".*" ] : [ ".*" ] :
(typeof result.matchingPatterns != "undefined" ? (typeof result.matchingPatterns != "undefined" ?
break; break;
} }
} }
if (!shouldKillSticky) return;
killSticky();
return shouldKillSticky;
}

function updateIcon(result) {
// TODO: code!
}

/******************/
/* INITIALIZATION */
/******************/

function initialize() {
chrome.storage.sync.get([ "matchingPatterns", "exclusionPatterns", "mode" ],
(result) => {
let shouldKillSticky = checkForShouldKillSticky(result);
updateIcon(result);
window.onload = () => {
if (shouldKillSticky) killSticky();
};
});
} }
initialize();

Загрузка…
Отмена
Сохранить