Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Dragging in pantheon Cookie Clicker [mobile]
- // @namespace http://tampermonkey.net/
- // @version 2025-07-25
- // @description try to take over the world!
- // @author You
- // @match https://orteil.dashnet.org/cookieclicker/
- // @icon https://www.google.com/s2/favicons?sz=64&domain=dashnet.org
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- const longPressDuration = 500;
- const moveThreshold = 10;
- let timerId = null;
- let startX = 0;
- let startY = 0;
- let isHolding = false;
- function dispatchMouseEvent(target, type, clientX, clientY) {
- target.dispatchEvent(new MouseEvent(type, {
- bubbles: true,
- cancelable: true,
- view: window,
- clientX,
- clientY
- }));
- }
- function handleStart(e) {
- const target = e.target;
- if (!(target.id && target.id.startsWith('templeGodDrag'))) return;
- if (isHolding) return;
- if (e.type.startsWith('touch')) {
- startX = e.touches[0].clientX;
- startY = e.touches[0].clientY;
- } else {
- startX = e.clientX;
- startY = e.clientY;
- }
- isHolding = true;
- timerId = setTimeout(() => {
- dispatchMouseEvent(target, 'mousedown', startX, startY);
- }, longPressDuration);
- }
- function handleMove(e) {
- if (!isHolding || !timerId) return;
- let currentX, currentY;
- if (e.type.startsWith('touch')) {
- currentX = e.touches[0].clientX;
- currentY = e.touches[0].clientY;
- } else {
- currentX = e.clientX;
- currentY = e.clientY;
- }
- if (Math.abs(currentX - startX) > moveThreshold || Math.abs(currentY - startY) > moveThreshold) {
- clearTimeout(timerId);
- timerId = null;
- isHolding = false;
- }
- }
- function handleEnd(e) {
- if (timerId) {
- clearTimeout(timerId);
- timerId = null;
- }
- isHolding = false;
- }
- document.addEventListener('mousedown', handleStart);
- document.addEventListener('touchstart', handleStart);
- document.addEventListener('touchmove', handleMove);
- document.addEventListener('mousemove', handleMove);
- document.addEventListener('mouseup', handleEnd);
- document.addEventListener('touchend', handleEnd);
- })();
Advertisement
Add Comment
Please, Sign In to add comment