Skip to content

Instantly share code, notes, and snippets.

@cuber
Created December 19, 2014 08:44
Show Gist options
  • Save cuber/cdfdbd5b89b14d915b97 to your computer and use it in GitHub Desktop.
Save cuber/cdfdbd5b89b14d915b97 to your computer and use it in GitHub Desktop.
886404 is ugly
var Searcher = {
a: function() {
so = this;
so.g();
window._r_ = false;
window.google = {
td: function(a, b, c) {
if (window._r_) return;
var h = c.d;
var t = h.match(/<font size="-1">[^,\d]*([,\d]+)[^,\d]*条结果[^\d]*(\d+)[^\d]*(用时 <b>(.*?)<\/b> 秒)&nbsp;<\/font>/);
if (!t) {
t = h.match(/<font size="-1">[^,\d]*([,\d]+)[^,\d]*条结果.*()(用时 <b>(.*?)<\/b> 秒)&nbsp;<\/font>/)
};
if (t === null) {
so.c([], [], {})
}
var d = [t[1], t[2], t[3]];
if (!d[1]) d[1] = "1";
var t = h.match(/<li><div class="g">(.*?)<\/table><\/div><\/li>/g);
var l = [];
for (var i = 0; i < t.length; i++) {
var e = {};
var f = t[i];
var g = f.match(/<h2 class="r"><a.*?href="([^"]*?)"[^>]*>(.*?)<\/a><\/h2>.*?<div class="std"><span class="s">(.*?)<\/span><br>/);
if (g) {
var j = g[1].length > 70 ? g[1].substring(0, 70) + '...' : g[1];
l.push([g[1], so.d(g[2]), so.d(g[3]), j])
}
}
if (l.length > 10) {
t = l[0];
l = l.slice(l.length - 9);
l.unshift(t)
}
var p = {};
t = h.match(/<div.*?id="navbar"[^>]*><table[^>]*>(.*?)<\/table>/);
if (t) {
h = t[1];
if (t) {
t = t[1].match(/<td[^>]*>.*?<a.*?href="([^"]*)"[^>]*>.*?上一页<\/span>/);
if (t) {
t = t[1].match(/&amp;start=(\d+)/);
if (t) {
p.p = t[1]
}
}
}
h = h.split('上一页');
if (h.length > 1) {
h = h[1]
} else {
h = h[0]
}
t = h.match(/<a.*?href="([^">]*?)"><div class="nr"><\/div><span>(\d+)<\/span>/g);
if (t) {
p.l = [];
for (var i = 0; i < t.length; i++) {
g = t[i].match(/&amp;start=(\d+)&amp;/);
ttt = t[i].match(/<span>(\d+)<\/span>/);
p.l.push([ttt[1], parseInt(g[1], 10)])
}
p.l.push([d[1], -1]);
p.l.sort(function sortNumber(a, b) {
return a[0] - b[0]
})
}
t = h.match(/<td[^>]*?class="b"[^>]*?><a[^>]*?href="([^"]*?)">/);
if (t) {
p.n = t[1].match(/&amp;start=(\d+)&amp;/)[1]
}
p.c = d[1]
}
so.c(d, l, p)
}
};
window.sl = function(a) {
window.location = '/search?q=' + window.w + (typeof a === 'undefined' ? '' : '&lr=' + a)
};
window.bdsc = function(a) {
if (a && a.s) {
window.rw = a.s
}
};
so.h();
if (!window.b) {
var k = ['58.123.102.99', 'wen.lu', '209.116.186.219', '203.116.165.138'];
for (var i in k) {
if (/^[^\d]/.test(k[i])) {
var m = 'https://'
} else {
var m = 'http://'
}
var u = m + k[i] + "/search?output=custom&newwindow=1" + ((window.s === '') ? '' : ("&start=" + window.s + "&sa=N")) + "&sugexp=ldymls&tch=4&fp=7912f7472892ef90&hl=zh-CN&q=" + window.w + (window.lr === '' ? '' : '&lr=' + window.lr);
so.f(u)
};
setTimeout(function() {
if (!window._r_) {
window._r_ = true;
so.c([], [], {})
}
}, window.t * 1000)
} else {
so.c([], [], {})
}
},
b: function(a) {
return document.getElementById(a)
},
c: function(b, c, d) {
var a = {
a: b,
b: 'script',
c: c,
d: d,
e: window.rw
};
template.config('escape', false);
this.b('content').innerHTML = template('search_result', a);
window._r_ = true;
this.i()
},
d: function(a) {
return a.replace(/<b>/g, '<em>').replace(/<\/b>/g, '</em>')
},
e: function(a) {
return document.getElementsByTagName(a)
},
f: function(a) {
var b = document.createElement("script");
b.type = "text/javascript";
b.src = a;
b.charset = "utf-8";
b.id = '_gs_' + (++this.j);
document.body.appendChild(b)
},
g: function() {
if (window.location.host !== 'www.886404.com') {
window.location = 'http://www.886404.com'
}
},
h: function() {
var a = 'http://unionsug.baidu.com/su?wd=' + window.w + '&cb=bdsc&t=' + (new Date()).getTime() * 1000;
this.f(a)
},
i: function() {
for (var i = 0; i < this.j; i++) {
this.b('_gs_' + (i + 1)).remove()
}
},
j: 0
};
Searcher.a();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment