Skip to content

Commit

Permalink
Add site-specific scriptlet
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Sep 29, 2023
1 parent 1ff3878 commit d3b95c1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}


/*******************************************************************************
*
Expand Down

0 comments on commit d3b95c1

Please sign in to comment.