您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Disable link draging and select text.
当前为
- // ==UserScript==
- // @name Select text inside a link like Opera
- // @namespace eight04.blogspot.com
- // @description Disable link draging and select text.
- // @include http://*
- // @include https://*
- // @version 2.0.4
- // @grant none
- // ==/UserScript==
- function OPLLS(){
- this.init.apply(this,arguments);
- }
- OPLLS.prototype={
- handleEvent: function(e){
- switch(e.type){
- case "mouseup":
- if(!getSelection().toString())break;
- // console.log("mouseup");
- var t=e.target;
- while(t.nodeName!="A" && t.nodeName!="HTML")t=t.parentNode;
- if(!t.href){
- // console.log("uninit");
- this.uninit();
- }
- break;
- case "click":
- if(!getSelection().toString()){
- // console.log("clicked and uninit");
- this.uninit();
- break;
- }
- e.preventDefault();
- e.stopPropagation();
- // console.log("selected and uninit");
- this.uninit();
- }
- },
- init: function(e){
- var t=e.target;
- if(t.nodeName=="IMG")return;
- while(t.nodeName!="A" && t.nodeName!="HTML")t=t.parentNode;
- if(!t.href)return;
- this._draggable = t.getAttribute("draggable");
- // console.log(this._draggable);
- t.draggable=false;
- this.ele = t;
- // console.log("OK");
- document.addEventListener("mouseup",this,true);
- document.addEventListener("click",this,true);
- },
- uninit: function(){
- document.removeEventListener("mouseup",this,true);
- document.removeEventListener("click",this,true);
- if(this._draggable === null)
- this.ele.removeAttribute("draggable");
- else
- this.ele.setAttribute("draggable", this._draggable.toString());
- }
- }
- document.addEventListener("mousedown",function(e){
- if(e.button!=0 || e.ctrlKey || e.altKey || e.shiftKey)return;
- new OPLLS(e);
- },false);