本站不兼容 8 以前的版本的 Interner Explorer 浏览器(或基于这些版本的 IE 的其他浏览器),并且页面样式不完全兼容 IE 8,我们建议你升级至 IE 9 或改用其他非 IE 浏览器

Mozest™

  • 正在加载用户菜单…

开放、分享、互助

转播到腾讯微博
返回列表 回复 发帖

[推荐] [书签]鼠标框选多个链接,释放鼠标后一次性打开所有链接

本帖最后由 qjahz 于 2009-8-20 05:54 编辑

大概有一阵子没有发书签脚本了吧
  1. javascript:(function(){

  2. var snapLinks = {
  3.         init : function(){
  4.                 this.flag = null;
  5.                 this.box = document.createElement('div');
  6.                 this.bs = this.box.style;
  7.                 this.bs.opacity = '0.3';
  8.                 this.bs.backgroundColor = 'blue';
  9.                 this.bs.position = 'absolute';
  10.                 this.bs.zIndex = '2147483647';
  11.                 this.defaultCursor = getComputedStyle(document.body, '').cursor;
  12.                 document.body.style.cursor = 'crosshair';
  13.                 document.addEventListener('mousedown', this, true);
  14.                 document.addEventListener('mousemove', this ,true);
  15.                 document.addEventListener('mouseup', this ,true);
  16.                 document.addEventListener('click', this, true);
  17.         },
  18.         uninit : function(){
  19.                 document.removeEventListener('mousedown', this, true);
  20.                 document.removeEventListener('mousemove', this, true);
  21.                 document.removeEventListener('mouseup', this, true);
  22.                 document.removeEventListener('click', this, true);
  23.                 document.body.removeChild(this.box);
  24.                 document.body.style.cursor = this.defaultCursor;
  25.         },
  26.         handleEvent : function(event){
  27.                 if (event.button != 0)
  28.                         return false;
  29.                 event.preventDefault();
  30.                 event.stopPropagation();
  31.                 switch(event.type){
  32.                         case 'mousedown':
  33.                                 this.downX = event.pageX;
  34.                                 this.downY = event.pageY;
  35.                                 this.bs.left = this.downX + 'px';
  36.                                 this.bs.top  = this.downY + 'px';
  37.                                 document.body.appendChild(this.box);
  38.                                 this.flag = true;
  39.                                 break;
  40.                         case 'mousemove':
  41.                                 if (!this.flag) return;
  42.                                 this.moveX = event.pageX;
  43.                                 this.moveY = event.pageY;
  44.                                 if (this.downX > this.moveX) this.bs.left = this.moveX + 'px';
  45.                                 if (this.downY > this.moveY) this.bs.top  = this.moveY + 'px';
  46.                                 this.bs.width  = Math.abs(this.moveX - this.downX) + 'px';
  47.                                 this.bs.height = Math.abs(this.moveY - this.downY) + 'px';
  48.                                 break;
  49.                         case 'mouseup':
  50.                                 if (event.shiftKey){
  51.                                         this.checkCommand();
  52.                                 }else{
  53.                                         this.linkCommand(event.ctrlKey);
  54.                                 }
  55.                                 this.uninit();
  56.                                 break;
  57.                 }
  58.         },
  59.         linkCommand : function(isAlert){
  60.                 var elems = this.getElements(document.links);
  61.                 if (elems.length == 0)
  62.                         return;

  63.                 if (isAlert){
  64.                         if (window.opera){
  65.                                 prompt(elems.length + ' Links', elems.join('\n'));
  66.                         }else{
  67.                                 alert(elems.join('\n'));
  68.                         }
  69.                         return;
  70.                 }
  71.                 elems.forEach(function(elem){
  72.                         window.open(elem.href);
  73.                 });
  74.         },
  75.         checkCommand : function(){
  76.                 var elems = this.getElements(document.getElementsByTagName('input'));
  77.                 if (elems.length == 0)
  78.                         return;

  79.                 elems.forEach(function(elem){
  80.                         if (elem.type == 'checkbox' || elem.type == 'radio')
  81.                                 elem.checked = !elem.checked;
  82.                 });
  83.         },
  84.         isInBox : function(elem){
  85.                 if (/^(javascript|#)/i.test(elem.getAttribute("href")))
  86.                         return false;
  87.                 var style = getComputedStyle(elem, null);
  88.                 if (style.visibility === 'hidden' || style.display === 'none' || style.opacity === '0')
  89.                         return false;
  90.                 var rect = elem.getBoundingClientRect();
  91.                 if (this.pos.left <= (rect.right + this.pos.scrX) && this.pos.right >= (rect.left + this.pos.scrX))
  92.                         if (this.pos.top <= (rect.bottom + this.pos.scrY) && this.pos.bottom >= (rect.top + this.pos.scrY))
  93.                                 return true;
  94.                 return false;
  95.         },
  96.         getElements : function(elems){
  97.                 var body = document.body;
  98.                 var html = document.documentElement;
  99.                 this.pos = {
  100.                         left : parseInt(this.bs.left),
  101.                         top : parseInt(this.bs.top),
  102.                         right : parseInt(this.bs.left) + parseInt(this.bs.width),
  103.                         bottom : parseInt(this.bs.top) + parseInt(this.bs.height),
  104.                         scrX : (body.scrollLeft || html.scrollLeft)- html.clientLeft,
  105.                         scrY : (body.scrollTop || html.scrollTop) - html.clientTop,
  106.                 };
  107.                 return Array.prototype.filter.call(elems, this.isInBox, this);
  108.         },
  109. };
  110. snapLinks.init();

  111. })();
复制代码

这个功能有ucjs脚本的。
这个功能有ucjs脚本的。
nettrottist 发表于 2009-8-20 06:10
哪个链接的ucjs?
本帖最后由 nettrottist 于 2009-8-20 07:14 编辑

http://g.mozest.com/viewthread.php?tid=26897&highlight=firegesture

原来是firegestures的功能。
用法是按住ctrl或者shift(自定义)。再按住鼠标右键拖过你欲打开的链接。
一次性打开大量标签页,快崩溃了
论坛的时间设置有问题。你看看发贴的时候怎么成了早上7:20.
论坛的时间设置有问题。你看看发贴的时候怎么成了早上7:20.
nettrottist 发表于 2009-8-20 07:28
论坛数据库问题应该只能金箭等管理员处理,修改服务器的时间设置
本帖最后由 长江九号 于 2009-8-21 17:50 编辑

脚本怎么用的呢?

怎么你的脚本放在书签里面?
试了下,非常不错,收藏
论坛数据库问题应该只能金箭等管理员处理,修改服务器的时间设置
qjahz 发表于 2009-8-20 07:41
ld都太忙了

本来以为是星球大战
看着看着就成三国赤壁了

论坛各版 置顶贴 最后发表
是时间机器版的吗?
很好用的脚本,谢谢了
同类的脚本或者扩展很容易跟已有的鼠标手势类扩展冲突,用起来反而麻烦

btw:可以改进加入链接打开的时间间隔么
真是好东西。
不过好像对图片链接无效吧。如果能支持图片链接就更好了
这个书签是不是对总tab的数量有所限制呢。我有3个页面,每个页面上都有10个链接。用这个bookmarklet将3个页面上的全部链接都打开,但在第三个页面里的链接就开不全了。
这个书签是不是对总tab的数量有所限制呢。我有3个页面,每个页面上都有10个链接。用这个bookmarklet将3个页面上的全部链接都打开,但在第三个页面里的链接就开不全了。 ...
hillhill 发表于 2009-10-11 21:10
对于这个问题,firefox本身就只能开十几个标签页的吧,
对于这个问题,firefox本身就只能开十几个标签页的吧,
qjahz 发表于 2009-10-12 07:13
原来如此,那能突破ff对标签数量的限制吗?
大概有一阵子没有发书签脚本了吧
javascript:(function(){

var snapLinks = {
        init : function(){
                this.flag = null;
                this.box = document.createElement('div');
        ...
qjahz 发表于 2009-8-20 05:50
是GM脚本吧,请问怎样使用要按什么键?用鼠标右键吗,可以点选链接吗