Skip to content

Instantly share code, notes, and snippets.

javascript:function a(){d=document,z=d.createElement('scr'+'ipt'),b=d.body;z.setAttribute('src','http://www.xuetianlu.com/t/hover.js');b.appendChild(z);}a();void(0)
javascript:function a(){d=document,z=d.createElement('scr'+'ipt'),j=d.createElement('scr'+'ipt'),b=d.body;z.setAttribute('src','http://www.xuetianlu.com/t/hover.js');j.setAttribute('src','http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.min.js');d.getElementsByTagName('head')[0].appendChild(j);b.appendChild(z);}a();void(0)
@tlxue
tlxue / gist:1021632
Created June 12, 2011 14:50
zhihu字体增大测试
javascript:(function(){var d=document,i,title=d.getElementsByClassName('mf'),action=d.getElementsByClassName('de'),para=d.getElementsByClassName('sk'),sub_action=d.getElementsByClassName('vf');function changeFontSize(element,size){for(i=0;i<element.length;i++){element[i].style.fontSize=size;}}
changeFontSize(title,'15px');changeFontSize(action,'13px');changeFontSize(para,'14px');changeFontSize(sub_action,'14px');})();
@tlxue
tlxue / gist:1094736
Created July 20, 2011 10:32
Baidu Transformers
var T, baidu = T = baidu || {
version: "1.3.9"
};
baidu.guid = "$BAIDU$";
window[baidu.guid] = window[baidu.guid] || {};
baidu.dom = baidu.dom || {};
baidu.browser = baidu.browser || {};
if (/msie (\d+\.\d)/i.test(navigator.userAgent)) {
baidu.browser.ie = baidu.ie = document.documentMode || +RegExp["\x241"]
}
@tlxue
tlxue / gist:1099088
Created July 22, 2011 08:26
ZH 答案链接生成
javascript:(function(){var url=window.location.href.replace(window.location.hash,'');if(url.indexOf('zhihu')==-1){return;}var obj=window['xxxxxxxx']||DZMT;if(!obj){return;}var q=obj[2][1];var ans=q[11];var list=[];for(var k=0;k<ans.length;k++){var aid=ans[k][0];var userName=ans[k][2][0];list.push(userName+': '+url+'#'+aid);}alert(list.join('\n'));})()
@tlxue
tlxue / gist:1099158
Created July 22, 2011 09:29
ZH 答案链接生成粉红版
javascript:%20(function(){var%20d=document,a=d.getElementsByName('nohelp'),b,url=window.location.href.slice(0,38),name,aid;function%20handleClick(){aid=this.parentNode.parentNode.id.slice(3)||'';name=this.parentNode.parentNode.childNodes[3].childNodes[1].childNodes[1].innerText;alert(name+":"+url+"#"+aid);}%20for(i=0;i<a.length;i++){a[i].nextSibling.nextSibling.className='temp_button';a[i].nextSibling.nextSibling.setAttribute('style','cursor:pointer;color:#FFBCD9');}%20b=d.getElementsByClassName('temp_button');for(i=0;i<b.length;i++){console.log(b[i]);b[i].addEventListener('click',handleClick,'false');}})();
javascript:%20(function(){var%20d=document,a=d.getElementsByName('nohelp'),b,url=window.location.href.slice(0,38),name,aid;function%20handleClick(){aid=this.parentNode.parentNode.id.slice(3)||'';name=this.parentNode.parentNode.childNodes[3].childNodes[1].childNodes[1].innerText;alert(name+":"+url+"#"+aid);}%20for(i=0;i<a.length;i++){if(a[i].nextSibling.nextSibling.innerText.length<3){a[i].nextSibling.nextSibling.nextSibling.nextSibling.className='temp_button';a[i].nextSibling.nextSibling.nextSibling.nextSibling.setAttribute('style','cursor:pointer;color:#FFBCD9');}else{a[i].nextSibling.nextSibling.className='temp_button';a[i].nextSibling.nextSibling.setAttribute('style','cursor:pointer;color:#FFBCD9');}}%20b=d.getElementsByClassName('temp_button');for(i=0;i<b.length;i++){console.log(b[i]);b[i].addEventListener('click',handleClick,'false');}})();
@tlxue
tlxue / gist:1105963
Created July 26, 2011 04:15
Tumblr share
javascript: var d = document,
w = window,
e = w.getSelection,
k = d.getSelection,
x = d.selection,
s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)),
f = 'http://www.tumblr.com/share',
l = d.location,
e = encodeURIComponent,
p = '?v=3&u=' + e(l.href) + '&t=' + e(d.title) + '&s=' + e(s),
@tlxue
tlxue / getPrime
Created July 26, 2011 18:06
Prime Number
(function(n){var a=0,i,j,n=n+1||101;for(i=1;i<n;i++){for(j=1;j<=i;j++){if(i%j===0){a+=1}}if(a<3){console.log(i)}a=0;}})()
@tlxue
tlxue / fixedVoteButton.js
Created August 9, 2011 04:29
Fix the postion of vote buttons when scrolling
// run this in a question page
// just a demo, compatibility hasn't been tested
(function(){
// utility
function s(syntax){
// a simple selector, support ID, Class and tag.
if(syntax&&typeof(syntax)==="string"){
if(/^#/.test(syntax)){
return document.getElementById(syntax.slice(1));
}else if(/^\./.test(syntax)){