您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
由于Web选择太好用,微软就把他砍掉了。本脚本实现了Web选择的部分功能。按下Alt+S即可选择文本。
当前为
// ==UserScript== // @name Web选择 // @name:en Web Select // @namespace http://howardzhangdqs.eu.org/ // @version 0.2 // @description 由于Web选择太好用,微软就把他砍掉了。本脚本实现了Web选择的部分功能。按下Alt+S即可选择文本。 // @description:en Due to the ease with which the "web select" was used, Microsoft cut it off. This script implements some functions of "web select". Press Alt+S to select text. // @author HowardZhangdqs // @match *://*/* // @license MIT // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABsUExURf///xYWFgMDAw4ODgICAh8fHw4ODQAAAA8PD9LS0gEBAR4eHgcHBwoKCgUFBQgICCAgICgoKCwsLB0dHSQkJCYmJvv7+vr6+ZiYlyMjIhwcHJaWlBsbGxgYGAYGBnV2dfz9/BAQEHR0cw0NDWBB0hYAAAFaSURBVFjD7VbZkoMgEARBwNvNsfed///HAJoUq3Ga1a0tH+ynQXragWmtYWzDelEopXzQmgu+/Jorxe9gOtceNjI6gF2X14hC0ic8MZYPBIJwGqonlSzIsHhkkQpu/xlVqKa3D3b7QJ+RLqHAlyRIisICaqkAXYE9YYKMAijYaTGU/0dWu+4+eL9DcjOm1J1DZZQP2jFF6qtARBvNiJK65FxK+TlTwOWnfXyaIZDZB9UvnHhT4HWpQLoJ/KGANcUH/h98EwJzvsSVCST6HiUMKT8EWtyFguyCWdrGxQJHLKCRkYDCzv2+yC644cCY7r78eCOEEd2aC+OHjh3lg2CIGI44TTh8TBupZx0nRxyBnFi4xGYw4rxc1uVKv4U9JGW0M96xeQiFHLoPnNLNtm+LrknTFWIBrgGhQm/oBoSUfAF9S1IjIKdUIF9iO5FF8ChL7it5EzVnG1aMM5cYFmmzQuXPAAAAAElFTkSuQmCC // @grant none // ==/UserScript== (()=>{"use strict";function e(){n(void 0,void 0,void 0,(function(){var e,n,r,l,i,c,s;return o(this,(function(o){switch(o.label){case 0:for(x=[],document.querySelectorAll("*").forEach((function(e){var t=(r=e.getBoundingClientRect()).top,n=r.left,o=r.width,r=r.height;t&&n&&o&&r&&e.innerText&&x.push({top:t,left:n,width:o,height:r,text:e.innerText,src:e})})),e=[],n=0,r=x;n<r.length;n++)l=r[n],e.push((v=void 0,d=l.top,p=l.left,h=l.width,f=l.height,y=l.text,a=l.src,(v=document.createElement("div")).style.position="fixed",v.style.top="".concat(d,"px"),v.style.left="".concat(p,"px"),v.style.width="".concat(h,"px"),v.style.height="".concat(f,"px"),v.style.border=t.UnselectedBoxStyle,v.style.zIndex="99999",document.body.appendChild(v),{top:d,left:p,width:h,height:f,text:y,el:v,src:a}));return[4,(u=e,new Promise((function(e,n){var o=document.createElement("div"),r=(o.style.position="fixed",o.style.top="0",o.style.left="0",o.style.width="0",o.style.height="0",o.style.border=t.SelectBoxStyle,o.style.borderRadius="6px",o.style.zIndex="99999",document.body.appendChild(o),{p1:[0,0],p2:[0,0],get top(){return Math.min(this.p1[0],this.p2[0])},get left(){return Math.min(this.p1[1],this.p2[1])},get width(){return Math.abs(this.p1[1]-this.p2[1])},get height(){return Math.abs(this.p1[0]-this.p2[0])}}),l=function(e){e.preventDefault(),r.p1=[e.clientY,e.clientX],r.p2=[e.clientY,e.clientX],o.style.top="".concat(r.top,"px"),o.style.left="".concat(r.left,"px"),o.style.width="0",o.style.height="0",document.addEventListener("mousemove",c),document.addEventListener("mouseup",s)},i=function(){return u.filter((function(e){return!(e.left<r.left||e.top<r.top||e.left+e.width>r.left+r.width||e.top+e.height>r.top+r.height)}))},c=function(e){e.preventDefault(),r.p2=[e.clientY,e.clientX],o.style.top="".concat(r.top,"px"),o.style.left="".concat(r.left,"px"),o.style.width="".concat(r.width,"px"),o.style.height="".concat(r.height,"px");for(var n=i(),l=0,c=u;l<c.length;l++){var s=c[l];n.includes(s)?s.el.style.border=t.SelectedBoxStyle:s.el.style.border=t.UnselectedBoxStyle}},s=function(t){document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",s),document.removeEventListener("mousedown",l),o.remove(),e({top:parseInt(o.style.top),left:parseInt(o.style.left),width:parseInt(o.style.width),height:parseInt(o.style.height),el:i()})};document.addEventListener("mousedown",l),document.addEventListener("mouseup",s)})))];case 1:for(s=o.sent(),i=0,c=e;i<c.length;i++)c[i].el.remove();return s=s.el.filter((function(e,t,n){for(var o=0,r=n;o<r.length;o++)if(function(e,t){for(var n=t.parentNode;null!==n;){if(n===e)return!0;n=n.parentNode}return!1}(r[o].src,e.src))return!1;return!0})).sort((function(e,t){return e.left-t.left})).sort((function(e,t){return e.top-t.top})),navigator.clipboard.writeText(s.map((function(e){return e.text})).join("\n\n")),[2]}var u,a,d,p,h,f,y,v,x}))}))}var t={UnselectedBoxStyle:"1px dashed grey",SelectedBoxStyle:"1px solid black",SelectBoxStyle:"2px solid red"},n=function(e,t,n,o){return new(n=n||Promise)((function(r,l){function i(e){try{s(o.next(e))}catch(e){l(e)}}function c(e){try{s(o.throw(e))}catch(e){l(e)}}function s(e){var t;e.done?r(e.value):((t=e.value)instanceof n?t:new n((function(e){e(t)}))).then(i,c)}s((o=o.apply(e,t||[])).next())}))},o=function(e,t){var n,o,r,l={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},i={next:c(0),throw:c(1),return:c(2)};return"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(n)throw new TypeError("Generator is already executing.");for(;l=i&&u[i=0]?0:l;)try{if(n=1,o&&(r=2&u[0]?o.return:u[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,u[1])).done)return r;switch(o=0,(u=r?[2&u[0],r.value]:u)[0]){case 0:case 1:r=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,o=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(r=0<(r=l.trys).length&&r[r.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3]))l.label=u[1];else if(6===u[0]&&l.label<r[1])l.label=r[1],r=u;else{if(!(r&&l.label<r[2])){r[2]&&l.ops.pop(),l.trys.pop();continue}l.label=r[2],l.ops.push(u)}}u=t.call(e,l)}catch(s){u=[6,s],o=0}finally{n=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}};window.addEventListener("keydown",(function(t){t.altKey&&"s"===t.key&&e()}))})();