Greasemonkey之GM_xmlhttpRequest:获取用户IP地点

 

// ==UserScript==
// @name        tt
// @namespace   tt
// @include     *
// @require     http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js
// @version     1
// @grant GM_xmlhttpRequest
// ==/UserScript==

var fullUrl = "http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js";

GM_xmlhttpRequest({
    method: 'GET',
    url: fullUrl,
    headers: {
        'User-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    },
    onload: function(responseDetails) {
        eval(responseDetails.responseText);
        var dz = remote_ip_info.country + " > " + remote_ip_info.province + " > " + remote_ip_info.city;
        alert(dz);
    }
});

效果图:

Greasemonkey之GM_xmlhttpRequest:获取用户IP地点_第1张图片

你可能感兴趣的:(Greasemonkey之GM_xmlhttpRequest:获取用户IP地点)