Skip to content

Commit

Permalink
Add refresh-defuser scriptlet
Browse files Browse the repository at this point in the history
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/
  • Loading branch information
gorhill committed Oct 3, 2021
1 parent 9cd69ce commit c0a43b0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit c0a43b0

Please sign in to comment.