From 24a8873891b2b233086e3f024e06d09c7baba3c1 Mon Sep 17 00:00:00 2001 From: "adamlui@protonmail.com" Date: Thu, 22 Aug 2024 03:56:29 -0700 Subject: [PATCH] Disabled non-left-click dragging in drag handlers --- amazongpt/greasemonkey/amazongpt.user.js | 7 +++++-- bravegpt/greasemonkey/bravegpt.user.js | 7 +++++-- duckduckgpt/greasemonkey/duckduckgpt.user.js | 8 ++++++-- googlegpt/greasemonkey/googlegpt.user.js | 7 +++++-- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/amazongpt/greasemonkey/amazongpt.user.js b/amazongpt/greasemonkey/amazongpt.user.js index 2ebbc8bebd..04880ec6c9 100644 --- a/amazongpt/greasemonkey/amazongpt.user.js +++ b/amazongpt/greasemonkey/amazongpt.user.js @@ -3,7 +3,7 @@ // @description Adds the magic of AI to Amazon shopping // @author KudoAI // @namespace https://kudoai.com -// @version 2024.8.22.1 +// @version 2024.8.22.2 // @license MIT // @icon https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon48.png?v=0fddfc7 // @icon64 https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon64.png?v=0fddfc7 @@ -448,7 +448,8 @@ dragHandlers: { mousedown(event) { // find modal, attach listeners, init XY offsets - if (getComputedStyle(event.target).cursor == 'pointer') return // don't activate drag when clicking on interactive elems + if (event.button != 0) return // prevent non-left-click drag + if (getComputedStyle(event.target).cursor == 'pointer') return // prevent drag when clicking on interactive elems modals.dragHandlers.draggableElem = event.currentTarget event.preventDefault(); // prevent sub-elems like icons being draggable ['mousemove', 'mouseup'].forEach(event => document.addEventListener(event, modals.dragHandlers[event])) @@ -1527,6 +1528,7 @@ // Add event listeners for dragging thumb let isDragging = false, startX, startLeft sliderThumb.addEventListener(inputEvents.down, event => { + if (event.button != 0) return // prevent non-left-click drag event.preventDefault() // prevent text selection isDragging = true ; startX = event.clientX ; startLeft = sliderThumb.offsetLeft document.body.appendChild(fontSizeSlider.cursorOverlay) @@ -1547,6 +1549,7 @@ // Add event listener for seek/dragging by inputEvents.down on track slider.addEventListener(inputEvents.down, event => { + if (event.button != 0) return // prevent non-left-click drag event.preventDefault() // prevent text selection const clientX = event.clientX || event.touches?.[0]?.clientX moveThumb(clientX - slider.getBoundingClientRect().left - sliderThumb.offsetWidth / 2) diff --git a/bravegpt/greasemonkey/bravegpt.user.js b/bravegpt/greasemonkey/bravegpt.user.js index 2067ac1876..42683044b4 100644 --- a/bravegpt/greasemonkey/bravegpt.user.js +++ b/bravegpt/greasemonkey/bravegpt.user.js @@ -148,7 +148,7 @@ // @description:zu Yengeza izimpendulo ze-AI ku-Brave Search (inikwa amandla yi-GPT-4o!) // @author KudoAI // @namespace https://kudoai.com -// @version 2024.8.22.1 +// @version 2024.8.22.2 // @license MIT // @icon https://media.bravegpt.com/images/icons/bravegpt/icon48.png?0a9e287 // @icon64 https://media.bravegpt.com/images/icons/bravegpt/icon64.png?0a9e287 @@ -592,7 +592,8 @@ setTimeout(async () => { dragHandlers: { mousedown(event) { // find modal, attach listeners, init XY offsets - if (getComputedStyle(event.target).cursor == 'pointer') return // don't activate drag when clicking on interactive elems + if (event.button != 0) return // prevent non-left-click drag + if (getComputedStyle(event.target).cursor == 'pointer') return // prevent drag when clicking on interactive elems modals.dragHandlers.draggableElem = event.currentTarget event.preventDefault(); // prevent sub-elems like icons being draggable ['mousemove', 'mouseup'].forEach(event => document.addEventListener(event, modals.dragHandlers[event])) @@ -2004,6 +2005,7 @@ setTimeout(async () => { // Add event listeners for dragging thumb let isDragging = false, startX, startLeft sliderThumb.addEventListener(inputEvents.down, event => { + if (event.button != 0) return // prevent non-left-click drag event.preventDefault() // prevent text selection isDragging = true ; startX = event.clientX ; startLeft = sliderThumb.offsetLeft document.body.appendChild(fontSizeSlider.cursorOverlay) @@ -2024,6 +2026,7 @@ setTimeout(async () => { // Add event listener for seek/dragging by inputEvents.down on track slider.addEventListener(inputEvents.down, event => { + if (event.button != 0) return // prevent non-left-click drag event.preventDefault() // prevent text selection const clientX = event.clientX || event.touches?.[0]?.clientX moveThumb(clientX - slider.getBoundingClientRect().left - sliderThumb.offsetWidth / 2) diff --git a/duckduckgpt/greasemonkey/duckduckgpt.user.js b/duckduckgpt/greasemonkey/duckduckgpt.user.js index c3daa9c060..8b1c241fef 100644 --- a/duckduckgpt/greasemonkey/duckduckgpt.user.js +++ b/duckduckgpt/greasemonkey/duckduckgpt.user.js @@ -148,7 +148,7 @@ // @description:zu Yengeza izimpendulo ze-AI ku-DuckDuckGo (inikwa amandla yi-GPT-4o!) // @author KudoAI // @namespace https://kudoai.com -// @version 2024.8.22.1 +// @version 2024.8.22.2 // @license MIT // @icon https://media.ddgpt.com/images/icons/duckduckgpt/icon48.png?af89302 // @icon64 https://media.ddgpt.com/images/icons/duckduckgpt/icon64.png?af89302 @@ -598,7 +598,8 @@ dragHandlers: { mousedown(event) { // find modal, attach listeners, init XY offsets - if (getComputedStyle(event.target).cursor == 'pointer') return // don't activate drag when clicking on interactive elems + if (event.button != 0) return // prevent non-left-click drag + if (getComputedStyle(event.target).cursor == 'pointer') return // prevent drag when clicking on interactive elems modals.dragHandlers.draggableElem = event.currentTarget event.preventDefault(); // prevent sub-elems like icons being draggable ['mousemove', 'mouseup'].forEach(event => document.addEventListener(event, modals.dragHandlers[event])) @@ -1907,6 +1908,7 @@ // Add event listeners for dragging thumb let isDragging = false, startX, startLeft sliderThumb.addEventListener(inputEvents.down, event => { + if (event.button != 0) return // prevent non-left-click drag event.preventDefault() // prevent text selection isDragging = true ; startX = event.clientX ; startLeft = sliderThumb.offsetLeft document.body.appendChild(fontSizeSlider.cursorOverlay) @@ -1927,6 +1929,7 @@ // Add event listener for seek/dragging by inputEvents.down on track slider.addEventListener(inputEvents.down, event => { + if (event.button != 0) return // prevent non-left-click drag event.preventDefault() // prevent text selection const clientX = event.clientX || event.touches?.[0]?.clientX moveThumb(clientX - slider.getBoundingClientRect().left - sliderThumb.offsetWidth / 2) @@ -3106,6 +3109,7 @@ // Create/ID/classify/listenerize DDGPT container const appDiv = document.createElement('div') ; appDiv.id = 'ddgpt' ; appDiv.classList.add('fade-in') appDiv.addEventListener(inputEvents.down, event => { // to dismiss visible font size slider + let elem = event.target while (elem && !(elem.id?.includes('font-size'))) // find font size elem parent to exclude handling down event elem = elem.parentNode diff --git a/googlegpt/greasemonkey/googlegpt.user.js b/googlegpt/greasemonkey/googlegpt.user.js index 7286414e4f..a505af0f7b 100644 --- a/googlegpt/greasemonkey/googlegpt.user.js +++ b/googlegpt/greasemonkey/googlegpt.user.js @@ -149,7 +149,7 @@ // @description:zu Yengeza izimpendulo ze-AI ku-Google Search (inikwa amandla yi-Google Gemma + GPT-4o!) // @author KudoAI // @namespace https://kudoai.com -// @version 2024.8.22.1 +// @version 2024.8.22.2 // @license MIT // @icon https://media.googlegpt.io/images/icons/googlegpt/black/icon48.png?8652a6e // @icon64 https://media.googlegpt.io/images/icons/googlegpt/black/icon64.png?8652a6e @@ -787,7 +787,8 @@ dragHandlers: { mousedown(event) { // find modal, attach listeners, init XY offsets - if (getComputedStyle(event.target).cursor == 'pointer') return // don't activate drag when clicking on interactive elems + if (event.button != 0) return // prevent non-left-click drag + if (getComputedStyle(event.target).cursor == 'pointer') return // prevent drag when clicking on interactive elems modals.dragHandlers.draggableElem = event.currentTarget event.preventDefault(); // prevent sub-elems like icons being draggable ['mousemove', 'mouseup'].forEach(event => document.addEventListener(event, modals.dragHandlers[event])) @@ -2222,6 +2223,7 @@ // Add event listeners for dragging thumb let isDragging = false, startX, startLeft sliderThumb.addEventListener(inputEvents.down, event => { + if (event.button != 0) return // prevent non-left-click drag event.preventDefault() // prevent text selection isDragging = true ; startX = event.clientX ; startLeft = sliderThumb.offsetLeft document.body.appendChild(fontSizeSlider.cursorOverlay) @@ -2242,6 +2244,7 @@ // Add event listener for seek/dragging by inputEvents.down on track slider.addEventListener(inputEvents.down, event => { + if (event.button != 0) return // prevent non-left-click drag event.preventDefault() // prevent text selection const clientX = event.clientX || event.touches?.[0]?.clientX moveThumb(clientX - slider.getBoundingClientRect().left - sliderThumb.offsetWidth / 2)