V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
luistrong
V2EX  ›  问与答

v2ex 新标签页打开链接

  •  
  •   luistrong · 2018-08-16 10:37:23 +08:00 · 2075 次点击
    这是一个创建于 2073 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    // ==UserScript== // @name 新标签打开 // @namespace http://tampermonkey.net/ // @version 0.6 // @description 常用网站新标签页打开 // @author [email protected] // @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; }

    });
    

    })();

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

    没成功..
    silencefent
        12
    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
        13
    745839  
       2018-08-16 14:39:52 +08:00
    @yuyu2140 学习到了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2841 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 14:07 · PVG 22:07 · LAX 07:07 · JFK 10:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.