Skip to content

Instantly share code, notes, and snippets.

@binux
Created April 23, 2011 02:20
Show Gist options
  • Save binux/938176 to your computer and use it in GitHub Desktop.
Save binux/938176 to your computer and use it in GitHub Desktop.

Revisions

  1. 足兆叉虫 revised this gist May 18, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion byr-bbs-ip2location.user.js
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@
    // @include http://bbs.byr.cn/*
    // @include http://bbs6.byr.cn/*
    // @include http://www.newsmth.net/*
    // @version 1.4
    // @version 1.5
    // @author Binux
    // ==/UserScript==

  2. 足兆叉虫 revised this gist May 18, 2012. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions byr-bbs-ip2location.user.js
    Original file line number Diff line number Diff line change
    @@ -33,16 +33,16 @@ function onLoad(event) {
    }

    function sendRequest(ip){
    GM_xmlhttpRequest({
    setTimeout(function() {GM_xmlhttpRequest({
    method: 'GET',
    url: 'http://www.youdao.com/smartresult-xml/search.s?type=ip&q='+ip,
    onload: function(responseDetails) {
    var response = responseDetails.responseText;
    var ip = response.match(/<ip>(.*)<\/ip>/)[1];
    var loc = response.match(/<location>(.*)<\/location>/)[1];
    showAddress({'ip': ip,'loc': loc});
    }
    });
    var response = responseDetails.responseText;
    var ip = response.match(/<ip>(.*)<\/ip>/)[1];
    var loc = response.match(/<location>(.*)<\/location>/)[1];
    showAddress({'ip': ip,'loc': loc});
    }
    })}, 0);
    }

    function showAddress(response){
  3. binux revised this gist Dec 5, 2011. 1 changed file with 3 additions and 12 deletions.
    15 changes: 3 additions & 12 deletions byr-bbs-ip2location.user.js
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@
    // @include http://bbs.byr.cn/*
    // @include http://bbs6.byr.cn/*
    // @include http://www.newsmth.net/*
    // @version 1.3.1
    // @version 1.4
    // @author Binux
    // ==/UserScript==

    @@ -52,16 +52,7 @@ function showAddress(response){
    }
    }

    var IP2LOC_DOCUMENT_HIGHT = document.height;
    function checkDom() {
    if (IP2LOC_DOCUMENT_HIGHT != document.height ) {
    IP2LOC_DOCUMENT_HIGHT = document.height;
    onLoad();
    }
    setTimeout("checkDom()", 500);
    }

    onLoad();
    setTimeout("checkDom()", 500);
    window.addEventListener("load", onLoad, false);
    window.addEventListener("AutoPagerAfterInsert", onLoad, false);
    window.addEventListener("AutoPagerAfterInsert", onLoad, false);
    document.addEventListener("DOMNodeInserted", onLoad, false);
  4. binux revised this gist Oct 10, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion byr-bbs-ip2location.user.js
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@
    // @include http://bbs.byr.cn/*
    // @include http://bbs6.byr.cn/*
    // @include http://www.newsmth.net/*
    // @version 1.3
    // @version 1.3.1
    // @author Binux
    // ==/UserScript==

  5. binux revised this gist Oct 10, 2011. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions byr-bbs-ip2location.user.js
    Original file line number Diff line number Diff line change
    @@ -61,6 +61,7 @@ function checkDom() {
    setTimeout("checkDom()", 500);
    }

    onLoad();
    setTimeout("checkDom()", 500);
    window.addEventListener("load", onLoad, false);
    window.addEventListener("AutoPagerAfterInsert", onLoad, false);
    setTimeout("checkDom()", 500);
    window.addEventListener("AutoPagerAfterInsert", onLoad, false);
  6. binux revised this gist Oct 10, 2011. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions byr-bbs-ip2location.user.js
    Original file line number Diff line number Diff line change
    @@ -52,7 +52,7 @@ function showAddress(response){
    }
    }

    var IP2LOC_DOCUMENT_HIGHT = 0;
    var IP2LOC_DOCUMENT_HIGHT = document.height;
    function checkDom() {
    if (IP2LOC_DOCUMENT_HIGHT != document.height ) {
    IP2LOC_DOCUMENT_HIGHT = document.height;
    @@ -61,4 +61,6 @@ function checkDom() {
    setTimeout("checkDom()", 500);
    }

    window.addEventListener("load", checkDom, false);
    window.addEventListener("load", onLoad, false);
    window.addEventListener("AutoPagerAfterInsert", onLoad, false);
    setTimeout("checkDom()", 500);
  7. binux revised this gist Sep 9, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion byr-bbs-ip2location.user.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    // @include http://bbs6.byr.edu.cn/*
    // @include http://bbs.byr.cn/*
    // @include http://bbs6.byr.cn/*
    // @include http://*.newsmth.net/*
    // @include http://www.newsmth.net/*
    // @version 1.3
    // @author Binux
    // ==/UserScript==
  8. binux revised this gist Sep 9, 2011. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions byr-bbs-ip2location.user.js
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,7 @@
    // @include http://bbs6.byr.edu.cn/*
    // @include http://bbs.byr.cn/*
    // @include http://bbs6.byr.cn/*
    // @include http://*.newsmth.net/*
    // @version 1.3
    // @author Binux
    // ==/UserScript==
  9. binux renamed this gist Apr 23, 2011. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  10. binux created this gist Apr 23, 2011.
    63 changes: 63 additions & 0 deletions byr-bbs-ip2location.user.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,63 @@
    // ==UserScript==
    // @name BYR BBS ip2location
    // @namespace http://bbs.byr.cn/
    // @description 使北邮人论坛用户发贴IP地址后附加物理地址信息
    // @include http://forum.byr.edu.cn/*
    // @include http://forum.byr.cn/*
    // @include http://bbs.byr.edu.cn/*
    // @include http://bbs6.byr.edu.cn/*
    // @include http://bbs.byr.cn/*
    // @include http://bbs6.byr.cn/*
    // @version 1.3
    // @author Binux
    // ==/UserScript==

    function onLoad(event) {
    var fonts = document.getElementsByTagName("font");
    for ( var i = 0,font;font = fonts[i];i++ )
    {
    var result = font.innerHTML.match(/\[FROM:\D{0,5}(\d+\.\d+\.\d+\.[0-9*]+)\]/);
    if(result && font.lastChild.nodeName != "SPAN")
    {
    var ip = result[1].replace("*","0");

    var span = document.createElement("span");
    span.innerHTML = " [ LOADING... ]";
    span.className = ip;
    font.appendChild(span);

    sendRequest(ip)
    }
    }
    }

    function sendRequest(ip){
    GM_xmlhttpRequest({
    method: 'GET',
    url: 'http://www.youdao.com/smartresult-xml/search.s?type=ip&q='+ip,
    onload: function(responseDetails) {
    var response = responseDetails.responseText;
    var ip = response.match(/<ip>(.*)<\/ip>/)[1];
    var loc = response.match(/<location>(.*)<\/location>/)[1];
    showAddress({'ip': ip,'loc': loc});
    }
    });
    }

    function showAddress(response){
    var spans = document.getElementsByClassName(response.ip);
    for(var i=0,span;span = spans[i];i++){
    span.innerHTML = " [" + response.loc + "] ";
    }
    }

    var IP2LOC_DOCUMENT_HIGHT = 0;
    function checkDom() {
    if (IP2LOC_DOCUMENT_HIGHT != document.height ) {
    IP2LOC_DOCUMENT_HIGHT = document.height;
    onLoad();
    }
    setTimeout("checkDom()", 500);
    }

    window.addEventListener("load", checkDom, false);