v2ex 新标签页打开链接

2018-08-16 10:37:23 +08:00
 luistrong

找了一个油猴脚本, 请问大神我需要怎么才能添加 V2EX 使其新标签页打开链接呢?

// ==UserScript== // @name 新标签打开 // @namespace http://tampermonkey.net/ // @version 0.6 // @description 常用网站新标签页打开 // @author hxtgirq710@qq.com // @match http*://.github.com/ // @match http*://laravel-china.org/* // @match http*://packagist.org/* // @match http*://cnodejs.org/* // @require https://code.jquery.com/jquery-latest.js // @grant none // ==/UserScript==

(function() { 'use strict'; $(function(){ switch(window.location.host) { case "packagist.org": setInterval(function(){ $(".package-item h4>a").attr("target", "_blank"); }, 1000); break; case "cnodejs.org": $(".cell a").attr("target", "_blank"); break; case "laravel-china.org": $(".list-group-item a").attr("target", "_blank"); break; default: $(".repo-list h3>a,#user-repositories-list h3>a").attr("target", "_blank"); break; }

});

})();

2077 次点击
所在节点    问与答
13 条回复
sikariba
2018-08-16 11:26:14 +08:00
Ctrl+鼠标左键不好用吗
luistrong
2018-08-16 11:27:48 +08:00
@sikariba #1 一直用的, 只是 CMD 键快点坏了.
yuyu2140
2018-08-16 11:29:15 +08:00
鼠标滚轮点击不好用吗
luistrong
2018-08-16 11:30:47 +08:00
@yuyu2140 #3 不用鼠标的..
silencefent
2018-08-16 12:08:08 +08:00
![]( )
silencefent
2018-08-16 12:09:29 +08:00
要等脚本生效,得加载完页面上这个 js,刚打开 v2 就点击页面链接是没法起作用的
yiying2020
2018-08-16 12:27:15 +08:00
luistrong
2018-08-16 12:29:37 +08:00
@silencefent #6 大神, 你太优秀了, 照着改完成功了.
luistrong
2018-08-16 12:31:08 +08:00
@yiying2020 #7 这个没效了
luistrong
2018-08-16 12:35:58 +08:00
@silencefent #6 忍不住再问一下, .item_title a 这个每个网站都不一样, 我要再去应用到 YouTube 威锋等网站, 要怎么找出关键词呢, 用 web 检查器可以吗?谢谢
luistrong
2018-08-16 12:46:38 +08:00
@silencefent #6 youtube 我这样写:
case "www.youtube.com": $(".video-title a").attr("target", "_blank");
break;

没成功..
silencefent
2018-08-16 14:21:37 +08:00
@luistrong
1>对所有网站 A 标签生效
// @match http*://*/*
case "*": $("a").attr("target", "_blank");
break;
2>
![]( )
粘贴 #r_6039210 > table > tbody > tr > td:nth-child(3) > div.reply_content > a
取最后两个节点
div.reply_content > a
example:
// @match http*://your sites/*
case "your sites": $("div.reply_content > a").attr("target", "_blank");
745839
2018-08-16 14:39:52 +08:00
@yuyu2140 学习到了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/480295

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX