Skip to content

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

Open
@gnipbao

Description

@gnipbao

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("我不是隐身模式");
   }
});

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions