防止垃圾站将父窗口跳转

在搜索引擎打开某些垃圾网站,会将搜索引擎跳转到其他页面,如果是跳转到一个高仿的登录(不可用)界面呢?所以写这个脚本消除这种安全隐患(打开任意外站链接其实都有这隐患)

当前为 2016-05-12 提交的版本,查看 最新版本

// ==UserScript==
// @name                        防止垃圾站将父窗口跳转
// @description         在搜索引擎打开某些垃圾网站,会将搜索引擎跳转到其他页面,如果是跳转到一个高仿的登录(不可用)界面呢?所以写这个脚本消除这种安全隐患(打开任意外站链接其实都有这隐患)
// @namespace   mh8xyk6hrntqalgcgxpwth32yi3zvpcl
// @author                      ejin
// @include        *
// @version                     2016.05.12
// @grant        none
// @run-at document-start
// ==/UserScript==

if ( document.location.protocol.indexOf("http") != -1 && (document.referrer.indexOf(location.href.split("/")[2]) == -1 || document.referrer.indexOf(location.href.split("/")[2]) > 10) ) {
	parent.window.opener=null; // 来源非本站时,禁掉parent.window.opener,防止js判断存在父窗口
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址