console.log("=========START=========="); var intClickOnButton = 0; var currentTabId = 0; function click_on_dbg_btn(tab) { console.log("calling click_on_dbg_btn | intClickOnButton = " + intClickOnButton + " | tab.url = " + tab.url); if (intClickOnButton) { chrome.cookies.remove({"url": tab.url, "name": "test_cookie"}, function (cookie){ if (cookie !== null) { console.log("## cookies.remove | remove cookie.name = " + cookie.name + " is succsessful"); console.log("## cookies.remove | remove cookie.name = " + cookie.name + " chrome.runtime.lastError = " + chrome.runtime.lastError + " chrome.runtime.lastError = " + chrome.runtime.lastError); intClickOnButton = 0; console.log("calling click_on_dbg_btn | intClickOnButton changes value to " + intClickOnButton); chrome.tabs.reload(currentTabId, {"bypassCache":true}); } else { console.log("## cookies.remove | remove " + cookie_name + " IS FAILED. Reason: " + chrome.runtime.lastError); } }); } else { chrome.cookies.set({"url": tab.url, "name": "test_cookie", "value":"1", "path":"/"}, function (cookie){ if (cookie !== null) { console.log("## cookies.set | set is succsessful"); console.log("## cookie.name = " + cookie.name + " cookie.value = " + cookie.value + " cookie.domain = " + cookie.domain + " chrome.runtime.lastError = " + chrome.runtime.lastError + " chrome.runtime.lastError = " + chrome.runtime.lastError); intClickOnButton = 1; console.log("click_on_dbg_btn | intClickOnButton changes value to " + intClickOnButton); chrome.tabs.reload(currentTabId, {"bypassCache":true}); } else { console.log("## cookies.set | set " + cookie_name + " = " + cookie_value + " IS FAILED. Reason: " + chrome.runtime.lastError); } } ); } } console.log("pageAction.onClicked.addListener | addListener"); chrome.pageAction.onClicked.addListener(function(tab) { click_on_dbg_btn(tab); }); console.log("tabs.onUpdated.addListener | addListener"); chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { currentTabId = tabId; if (tab.url !== "chrome://newtab/") { chrome.pageAction.show(currentTabId); console.log("tabs.onUpdated | currentTabId = " + currentTabId + "| URL = " + tab.url); }; }); console.log("=====================END");