Chrome插件英雄榜085《nonstop》无感跳转到知乎,微博,简书,qq 邮箱等无法直接跳转的外链


title: Chrome插件英雄榜085《nonstop》无感跳转到知乎,微博,简书,qq 邮箱等无法直接跳转的外链

nonstop国内下载链接

https://zhaoolee.lanzoux.com/b00nnabad

image-20201215092539974

获取安装包后,解压安装即可

演示图

2020-12-15-nonstop-new-09-27

nonstop开源

开源地址: https://github.com/yuxiaoy1/nonstop

核心代码就只有不到30行,非常安全透明,无需担心信息泄露(支持关闭知乎登录界面, 知乎, 微博, QQ邮箱, 简书链接自动重定向)

(function() {
    'use strict'
    let href = window.location.href
    if (href.indexOf('www.zhihu.com/question/') != -1) {
        // 关闭知乎登录页面
        window.onload = () => {
            let btn = document.querySelector('.Button.Modal-closeButton.Button--plain')
            if (btn) btn.click()
            return
        }
    }
    // 知乎, 微博, QQ邮箱, 简书链接自动重定向
    let link = document.querySelector('.link') || document.querySelector('.safety-url')
    let url = link ? link.textContent : ''
    if (url) {
        window.location.href = url
        return
    }

    // redirect for jianshu site
    let getParams = field => {
        let urlObject = new URL(href)
        let res = urlObject.searchParams.get(field)
        return res
    }
    url = getParams('url')
    if (url) window.location.href = url
})()

看到一则留言

image-20201216191149485

我在 https://www.v2fy.com/p/085-nonstop-2020-12-15/ 看到留言,有的小伙伴,希望推出油猴版本, 于是我稍微改了一下.

油猴版本

如果不知什么是油猴可以来这里: https://www.v2fy.com/p/004_tampermonkey/

// ==UserScript==
// @name         nonstop
// @namespace    http://tampermonkey.net/
// @include    *://*.zhihu.com/*
// @include    *://*.jianshu.com/*
// @include    *://*.weibo.com/*
// @include    *://*.t.cn.com/*
// @include    *://*.qq.com/*
// @version      0.1
// @description  try to take over the world!
// @author       zhaoolee
// @match        http://*/*
// @grant        none
// ==/UserScript==



(function() {
    'use strict';
    let href = window.location.href
    if (href.indexOf('www.zhihu.com/question/') != -1) {
        // 关闭知乎登录页面
        window.onload = () => {
            let btn = document.querySelector('.Button.Modal-closeButton.Button--plain')
            if (btn) btn.click()
            return
        }
    }
    // 知乎, 微博, QQ邮箱, 简书链接自动重定向
    let link = document.querySelector('.link') || document.querySelector('.safety-url')
    let url = link ? link.textContent : ''
    if (url) {
        window.location.href = url
        return
    }

    // redirect for jianshu site
    let getParams = field => {
        let urlObject = new URL(href)
        let res = urlObject.searchParams.get(field)
        return res
    }
    url = getParams('url')
    if (url) window.location.href = url

    // Your code here...
})();

使用方法

在油猴新建脚本,粘贴以上代码, Ctrl+s 保存代码即可

nonstop-tampermonkey

无感跳转js代码改造为油猴脚本方法解密

image-20201216192702211

《nonstop》下载地址

https://github.com/yuxiaoy1/nonstop

小结

外链无法直接跳转的设置,设计之初只是为了避免用户进入垃圾网站, 但随着各平台审核力度的增大, 已经很少能看到垃圾网站链接了, 而跳转确认页面反而影响了用户体验.

nonstop 用不到30行代码解决了用户跳转确认的问题, 是极其优秀的小工具.