permalinks: Only handle unmodified left clicks

Allow using Ctrl+click to open the link in a new tab, or Alt+click to
select the text, without annoying side effects.

Change-Id: I3ab4c1ec3d5fc6c69e7f44489bbe63c536a64b91
This commit is contained in:
Bartosz Dziewoński 2024-07-02 10:38:34 +02:00
parent 9f9a73c746
commit eb497b00c7

View file

@ -1,5 +1,11 @@
const utils = require( './utils.js' );
function init( $pageContainer ) { function init( $pageContainer ) {
$pageContainer.find( '.ext-discussiontools-init-timestamplink' ).on( 'click', ( e ) => { $pageContainer.find( '.ext-discussiontools-init-timestamplink' ).on( 'click', ( e ) => {
if ( !utils.isUnmodifiedLeftClick( e ) ) {
// Only handle unmodified left clicks
return;
}
// Try to percent-decode the URL, so that non-Latin characters don't look so ugly (T357021) // Try to percent-decode the URL, so that non-Latin characters don't look so ugly (T357021)
// Use currentTarget rather than target to avoid conflicts with userscripts that do their // Use currentTarget rather than target to avoid conflicts with userscripts that do their
// own timestamp-wrapping. (T368701) // own timestamp-wrapping. (T368701)