Skip to content

Commit c0a43b0

Browse files
committed
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/
1 parent 9cd69ce commit c0a43b0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

assets/resources/scriptlets.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,27 @@
723723
})();
724724

725725

726+
/// refresh-defuser.js
727+
// https://www.reddit.com/r/uBlockOrigin/comments/q0frv0/while_reading_a_sports_article_i_was_redirected/hf7wo9v/
728+
(function() {
729+
const arg1 = '{{1}}';
730+
const defuse = ( ) => {
731+
const meta = document.querySelector('meta[http-equiv="refresh" i][content]');
732+
if ( meta === null ) { return; }
733+
const s = arg1 === '' || arg1 === '{{1}}'
734+
? meta.getAttribute('content')
735+
: arg1;
736+
const ms = Math.max(parseFloat(s) || 0, 0) * 1000;
737+
setTimeout(( ) => { window.stop(); }, ms);
738+
};
739+
if ( document.readyState === 'loading' ) {
740+
document.addEventListener('DOMContentLoaded', defuse, { once: true });
741+
} else {
742+
defuse();
743+
}
744+
})();
745+
746+
726747
/// remove-attr.js
727748
/// alias ra.js
728749
(function() {

0 commit comments

Comments
 (0)