mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-28 04:13:43 +03:00
24 lines
570 B
JavaScript
24 lines
570 B
JavaScript
|
'use strict';
|
||
|
|
||
|
/* `setTimeout` changes context of execution from other window
|
||
|
(e.g. popup) to background window, so we may catch errors
|
||
|
in bg error handlers.
|
||
|
More: https://bugs.chromium.org/p/chromium/issues/detail?id=357568
|
||
|
*/
|
||
|
// Fix error context of methods of all APIs.
|
||
|
for(const api of Object.keys(window.apis)) {
|
||
|
for(const prop of Object.keys(api)) {
|
||
|
if ( typeof(api[prop]) !== 'function' ) {
|
||
|
continue;
|
||
|
}
|
||
|
const method = api[prop];
|
||
|
api[prop] = function(...args) {
|
||
|
|
||
|
setTimeout(method.bind(this, ...args), 0);
|
||
|
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|