Skip to content

Instantly share code, notes, and snippets.

@liberize
Last active July 15, 2021 15:47
Show Gist options
  • Save liberize/11262187 to your computer and use it in GitHub Desktop.
Save liberize/11262187 to your computer and use it in GitHub Desktop.

Revisions

  1. liberize renamed this gist Apr 24, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. liberize created this gist Apr 24, 2014.
    58 changes: 58 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    // ==UserScript==
    // @name 禁止google结果跳转
    // @namespace http://blog.whosemind.net
    // @description 去掉google搜索结果的跳转(http://www.google.com/url?), 而直接用原始链接
    // @version 0.0.7
    // @include /^https?:\/\/www\.google\.[^\/]+?\/(#.*|webhp.*|search\?.*)?$/
    // ==/UserScript==
    var eles,
    timer,
    s,
    parse,
    url,
    loop = function () {
    var fn = function () {
    try {
    console.log('looping... ');
    var res = document.getElementsByClassName('l'),
    eid = document.getElementById('rso'),
    v = document.getElementById('lst-ib') .value,
    l = res.length,
    end = function () {
    setTimeout(function () {
    eles = eid;
    s = v;
    //console.log(l);
    for (var i = 0; i < l; i++) {
    res[i].setAttribute('onmousedown', '');
    }
    console.log('done');
    clearInterval(timer);
    }, 10);
    },
    sf = document.getElementById('tsf'),
    ofn = sf.onsubmit;
    if (!_flag) {
    _flag = true;
    sf.onsubmit = function () {
    console.log('11');
    return ofn.apply(this, arguments);
    };
    }
    eid = eid ? eid.getAttribute('eid') : '';
    //l && console.log(eid);
    if (l && (eid !== eles || v == s)) {
    end();
    }
    unsafeWindow.rwt = function () {
    };
    } catch (e) {
    }
    };
    clearInterval(timer);
    timer = setInterval(fn, 1000);
    fn();
    },
    _flag;
    loop();
    unsafeWindow.addEventListener('hashchange', loop, false);