您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Simulate mouse events
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/21750/138530/simulate_event.js
- //// ==UserScript==
- // @name simulate_event
- // @namespace https://raw.githubusercontent.com/sergeych/jsnippets/master/simulate_event.js
- // ==/UserScript==
- /**
- * $('#foo').simulate('click'[,options]); // => fires "click" event on an element with id=foo
- * Prototype's idea, modified to run under jQuery
- *
- * - options: optional object to fine-tune event properties - pointerX, pointerY, ctrlKey, etc.
- *
- **/
- (function(){
- var eventMatchers = {
- 'HTMLEvents': /^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,
- 'MouseEvents': /^(?:click|mouse(?:down|up|over|move|out))$/
- };
- var defaultOptions = {
- pointerX: 0,
- pointerY: 0,
- button: 0,
- ctrlKey: false,
- altKey: false,
- shiftKey: false,
- metaKey: false,
- bubbles: true,
- cancelable: true
- };
- jQuery.fn.simulate = function(eventName) {
- var element = this[0];
- var options = $.extend(true, defaultOptions, arguments[2] || { });
- var oEvent, eventType = null;
- for (var name in eventMatchers) {
- if (eventMatchers[name].test(eventName)) { eventType = name; break; }
- }
- if (!eventType)
- throw new SyntaxError('Only HTMLEvents and MouseEvents interfaces are supported');
- if (document.createEvent) {
- oEvent = document.createEvent(eventType);
- if (eventType == 'HTMLEvents') {
- oEvent.initEvent(eventName, options.bubbles, options.cancelable);
- }
- else {
- oEvent.initMouseEvent(eventName, options.bubbles, options.cancelable, document.defaultView,
- options.button, options.pointerX, options.pointerY, options.pointerX, options.pointerY,
- options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.button, element);
- }
- element.dispatchEvent(oEvent);
- }
- else {
- options.clientX = options.pointerX;
- options.clientY = options.pointerY;
- oEvent = $.extend(document.createEventObject(), options);
- element.fireEvent('on' + eventName, oEvent);
- }
- return element;
- };
- })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址