mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-27 20:03:45 +03:00
+1 to robustness of onTabUpdate
This commit is contained in:
parent
d1e3b4f612
commit
b8c1b325e4
|
@ -11,33 +11,32 @@
|
||||||
https://github.com/ilyaigpetrov/repository-for-chrome-bugs/blob/master/browserAction-title-lost-after-setting/background.js
|
https://github.com/ilyaigpetrov/repository-for-chrome-bugs/blob/master/browserAction-title-lost-after-setting/background.js
|
||||||
Crazy parallel Chrome.
|
Crazy parallel Chrome.
|
||||||
**/
|
**/
|
||||||
window.onTabUpdated = {};
|
window._tabCallbacks = {};
|
||||||
|
|
||||||
chrome.tabs.onRemoved.addListener( tabId => delete window.onTabUpdated[tabId] );
|
|
||||||
|
|
||||||
function afterTabUpdated(tabId, cb) {
|
function afterTabUpdated(tabId, cb) {
|
||||||
if (window.onTabUpdated[tabId])
|
if (window._tabCallbacks[tabId])
|
||||||
window.onTabUpdated[tabId].push(cb);
|
window._tabCallbacks[tabId].push(cb);
|
||||||
else window.onTabUpdated[tabId] = [cb];
|
else window._tabCallbacks[tabId] = [cb];
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
|
function onTabUpdate(tabId) {
|
||||||
if (window.onTabUpdated[tabId]) {
|
if (window._tabCallbacks[tabId]) {
|
||||||
window.onTabUpdated[tabId].map( f => f() );
|
window._tabCallbacks[tabId].map( f => f() );
|
||||||
delete window.onTabUpdated[tabId];
|
delete window._tabCallbacks[tabId];
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
chrome.tabs.onUpdated.addListener( onTabUpdate );
|
||||||
|
chrome.tabs.onRemoved.addListener( onTabUpdate );
|
||||||
|
|
||||||
var previousUpdateTitleFinished = Promise.resolve();
|
var previousUpdateTitleFinished = Promise.resolve();
|
||||||
|
|
||||||
function blockInform(requestDetails) {
|
function blockInform(requestDetails) {
|
||||||
|
|
||||||
console.log(requestDetails.ip, requestDetails);
|
if (
|
||||||
|
requestDetails.tabId === -1 || // Not inside tab.
|
||||||
if (requestDetails.tabId === -1 || !window.antiCensorRu.pacProvider || !window.antiCensorRu.pacProvider.proxyIps || !window.antiCensorRu.pacProvider.proxyIps[ requestDetails.ip ])
|
!window.antiCensorRu.pacProvider || !window.antiCensorRu.pacProvider.proxyIps || !window.antiCensorRu.pacProvider.proxyIps[ requestDetails.ip ]
|
||||||
return;
|
) return;
|
||||||
|
|
||||||
console.log('UNBLOCK');
|
|
||||||
|
|
||||||
previousUpdateTitleFinished = previousUpdateTitleFinished.then(
|
previousUpdateTitleFinished = previousUpdateTitleFinished.then(
|
||||||
() => new Promise(
|
() => new Promise(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user