1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-05 11:37:01 +02:00

Add refresh-defuser scriptlet

To specifically defuse the reloading of a document through
a meta "refresh" tag.

Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/q0frv0/

As per solution from AdGuard:
- https://www.reddit.com/r/uBlockOrigin/comments/q0frv0/while_reading_a_sports_article_i_was_redirected/hf7wo9v/
This commit is contained in:
Raymond Hill 2021-10-03 09:46:24 -04:00
parent 9cd69ce1bd
commit c0a43b0d32
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -723,6 +723,27 @@
})();
/// refresh-defuser.js
// https://www.reddit.com/r/uBlockOrigin/comments/q0frv0/while_reading_a_sports_article_i_was_redirected/hf7wo9v/
(function() {
const arg1 = '{{1}}';
const defuse = ( ) => {
const meta = document.querySelector('meta[http-equiv="refresh" i][content]');
if ( meta === null ) { return; }
const s = arg1 === '' || arg1 === '{{1}}'
? meta.getAttribute('content')
: arg1;
const ms = Math.max(parseFloat(s) || 0, 0) * 1000;
setTimeout(( ) => { window.stop(); }, ms);
};
if ( document.readyState === 'loading' ) {
document.addEventListener('DOMContentLoaded', defuse, { once: true });
} else {
defuse();
}
})();
/// remove-attr.js
/// alias ra.js
(function() {