<commit_before>var testStyle = "body {background: azure!important;}";
var setStyle = "document.body.style.background = 'lime!important'; console.log('WEBSAUCE', document.body)";
var hostnames = [];
chrome.pageAction.onClicked.addListener(function(tab) {
  url = 'editor.html#' + new URL(tab.url).hostname;
  chrome.tabs.create({ url: url });
});

chrome.tabs.onUpdated.addListener(function(tabId, info, tab){
  if( info.url ) {
    var protocol = new URL(tab.url).protocol;
    if( protocol === "http:" || protocol === "https:" ){
      chrome.pageAction.show(tabId);
    }
    else{
      chrome.pageAction.hide(tabId);
    }
  }
});

chrome.tabs.onUpdated.addListener(function(tabId, info, tab){
  if( info.url || info.status === "loading"){
    var url = new URL(tab.url)
    if( url.protocol !== "http:" && url.protocol !== "https:" ){
      return;
    }
    var hostname = url.hostname;
    console.log(hostname, "UPDATED");
    if(true || hostnames.indexOf(hostname) !== -1){
      var cssKey = "CSS_#"+hostname;
      var jsKey = "js_#"+hostname;
      chrome.storage.local.get(cssKey, function(data){
        console.log(cssKey, data);
        if(data[cssKey]){
          chrome.tabs.insertCSS(tabId, {
            code: String(data[cssKey]),
            runAt: "document_start",
          });
        }
      });
      chrome.storage.local.get(jsKey, function(data){
        console.log(jsKey, data);
        if(data[jsKey]){
          chrome.tabs.executeScript(tabId, {
            code: String(data[jsKey]),
            runAt: "document_start",
          });
        }
      });
    }
  }
});<commit_msg>Show page action on reload and on extension start<commit_after>var hostnames = [];
chrome.pageAction.onClicked.addListener(function(tab) {
  url = 'editor.html#' + new URL(tab.url).hostname;
  chrome.tabs.create({ url: url });
});

chrome.tabs.query({}, function(results){
  for(var i in results){
    var tab = results[i];
    handlePageAction(tab);
  }
});

chrome.tabs.onUpdated.addListener(function(tabId, info, tab){
  if( info.status === "loading" ) {
    handlePageAction(tab);
  }
});

chrome.tabs.onUpdated.addListener(function(tabId, info, tab){
  console.log(info);
  if( info.url || info.status === "loading"){
    var url = new URL(tab.url)
    if( url.protocol !== "http:" && url.protocol !== "https:" ){
      return;
    }
    var hostname = url.hostname;
    console.log(hostname, "UPDATED");
    if(true || hostnames.indexOf(hostname) !== -1){
      var cssKey = "CSS_#"+hostname;
      var jsKey = "js_#"+hostname;
      chrome.storage.local.get(cssKey, function(data){
        console.log(cssKey, data);
        if(data[cssKey]){
          chrome.tabs.insertCSS(tabId, {
            code: String(data[cssKey]),
            runAt: "document_start",
          });
        }
      });
      chrome.storage.local.get(jsKey, function(data){
        console.log(jsKey, data);
        if(data[jsKey]){
          chrome.tabs.executeScript(tabId, {
            code: String(data[jsKey]),
            runAt: "document_start",
          });
        }
      });
    }
  }
});

function handlePageAction(tab){
  var protocol = new URL(tab.url).protocol;
  if( protocol === "http:" || protocol === "https:" ){
    chrome.pageAction.show(tab.id);
  }
  else{
    chrome.pageAction.hide(tab.id);
  }
}
{'fraction_non_alphanumeric': 0.1737428485395965, 'fraction_numerical': 0.0006022282445046673, 'mean_word_length': 2.753672316384181, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2177817', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1095, 'n_words': 190}