Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何使用JavaScript检测Google Chrome浏览器隐身模式 #29

Open
gnipbao opened this issue Sep 13, 2018 · 0 comments
Open

如何使用JavaScript检测Google Chrome浏览器隐身模式 #29

gnipbao opened this issue Sep 13, 2018 · 0 comments

Comments

@gnipbao
Copy link
Owner

gnipbao commented Sep 13, 2018

image

原理

利用开启隐身模式的chrome浏览器不能通过 requestFileSystem Api 访问系统文件的特点作为hack依据进行检测。

检测函数

/**
 * Determine wheter the incognito mode of Google Chrome is available or not.
 * 
 * @param callback Anonymous function executed when the availability of the incognito mode has been checked.
 */
function isIncognito(callback){
    var fs = window.RequestFileSystem || window.webkitRequestFileSystem;

    if (!fs) {
        callback(false);
    } else {
        fs(window.TEMPORARY,
            100,
            callback.bind(undefined, false),
            callback.bind(undefined, true)
        );
    }
}

How to use

isIncognito(function(itIs){
   if(itIs){
       console.log("我是隐身模式");
   }else{
       console.log("我不是隐身模式");
   }
});
@gnipbao gnipbao changed the title 如何使用javascript检测Google Chrome浏览器隐身模式 如何使用JavaScript检测Google Chrome浏览器隐身模式 Sep 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant