From d3b95c1c682d4ee5c592f08c1e7372dbd8dfd9c2 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 29 Sep 2023 12:51:44 -0400 Subject: [PATCH] Add site-specific scriptlet Related issue: https://github.com/uBlockOrigin/uAssets/issues/19903 --- assets/resources/scriptlets.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/assets/resources/scriptlets.js b/assets/resources/scriptlets.js index e22b8950e..22c8574c6 100644 --- a/assets/resources/scriptlets.js +++ b/assets/resources/scriptlets.js @@ -3452,6 +3452,29 @@ function preventCanvas( }); } +/******************************************************************************/ + +builtinScriptlets.push({ + name: 'multiup.js', + fn: multiup, + world: 'ISOLATED', +}); +function multiup() { + const handler = ev => { + const target = ev.target; + if ( target.matches('button[link]') === false ) { return; } + const ancestor = target.closest('form'); + if ( ancestor === null ) { return; } + if ( ancestor !== target.parentElement ) { return; } + const link = (target.getAttribute('link') || '').trim(); + if ( link === '' ) { return; } + ev.preventDefault(); + ev.stopPropagation(); + document.location.href = link; + }; + document.addEventListener('click', handler, { capture: true }); +} + /******************************************************************************* *