zoukankan      html  css  js  c++  java
  • 黄聪:Greasemonkey研究,通过GM_xmlhttpRequest获取远程URL的内容

    最近开发火狐,没有任何工具开发程序真的好痛苦,调试JS,只能先依赖Greasemonkey了,今天测试了一下用GM_xmlhttpRequest获取远程URL的内容。在此马克一下。

    // ==UserScript==
    // @name        GetDZ
    // @namespace   hcsem.com
    // @description 从新浪获取当前地址
    // @version     1
    // @run-at      document-end
    // @require     http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
    // @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/4.0 (compatible) Greasemonkey',
            'Accept': 'application/atom+xml,application/xml,text/xml',
        },
        onload: function(responseDetails) {
            
            eval( responseDetails.responseText );
            var dz = remote_ip_info.country + " > " + remote_ip_info.province + " > " + remote_ip_info.city;
            alert(dz);
        }
    });

    运行结果:

  • 相关阅读:
    基本命令
    Unicode Locale
    二进制查看编辑
    java reg
    java util
    js util
    跑到X
    [转]Linux AIO :libaio
    [转]c++ atomic操作
    [转] dpdk笔记
  • 原文地址:https://www.cnblogs.com/huangcong/p/3129830.html
Copyright © 2011-2022 走看看