Skip to content

Instantly share code, notes, and snippets.

@dshoreman
Created May 7, 2022 09:31
Show Gist options
  • Save dshoreman/b4144d0534bd8b862b2c5da3a3abc3f3 to your computer and use it in GitHub Desktop.
Save dshoreman/b4144d0534bd8b862b2c5da3a3abc3f3 to your computer and use it in GitHub Desktop.
Tesco: Prevent ctrl-click hijacking
// ==UserScript==
// @name Tesco.com Click Fixer
// @namespace Violentmonkey Scripts
// @match https://www.tesco.com/*
// @grant none
// @version 1.0
// @author -
// @description 07/05/2022, 09:32:38
// ==/UserScript==
document.addEventListener('click', e => {
let t = e.target;
if (1 !== e.which || !e.ctrlKey || 'BUTTON' == t.tagName) {
return;
}
e.stopPropagation();
e.preventDefault();
if (t.tagName != 'A') {
t = t.closest('a');
}
window.open(t.href, '_blank');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment