Last active
August 29, 2015 14:01
-
-
Save wenketel/774227b69814e11465d7 to your computer and use it in GitHub Desktop.
寂寞的原子脚本备份
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Baidu Multiuser | |
// @namespace http://gera2ld.blog.163.com/ | |
// @author Gerald <[email protected]> | |
// @version 1.4.3 | |
// @description 百度马甲切换 | |
// @homepage http://userscripts.org/scripts/show/160577 | |
// @downloadURL https://userscripts.org/scripts/source/160577.user.js | |
// @updateURL https://userscripts.org/scripts/source/160577.meta.js | |
// @match *://*.baidu.com/* | |
// @include *.baidu.com/* | |
// @exclude http://developer.baidu.com/* | |
// @exclude http://web.im.baidu.com/* | |
// @require https://greasyfork.org/scripts/1046-tieba-common/code/Tieba_Common.js | |
// @grant GM_getValue | |
// @grant GM_setValue | |
// @grant GM_openInTab | |
// @grant GM_registerMenuCommand | |
// ==/UserScript== | |
function e(e,t){var o=GM_getValue(e,"");return o&&"string"==typeof o&&(o=JSON.parse(o)),o||t}function t(e,t){GM_setValue(e,JSON.stringify(t))}function o(e,t){var o=new Date;e?o.setTime(16094e8):e="",document.cookie="BDUSS="+e+";domain=baidu.com;path=/;expires="+o.toGMTString(),"function"==typeof t?t():"string"==typeof t?location.replace(t):location.reload()}function i(){v.right=v._right=v.parentNode.offsetWidth-v.offsetWidth-v.offsetLeft,v.top=v._top=v.offsetTop}function n(){t("ge_users",k)}function a(){t("ge_users_loc",{right:v.right,top:v.top})}function s(e,t,i){e.preventDefault(),i=e.target,e=i.parentNode,t=e.parentNode,"A"==i.tagName?e==t.firstChild?o():e==t.lastChild?GM_openInTab("http://wappass.baidu.com/?login&u=http://www.baidu.com"):o(k[i.innerText||i.textContent]):"SPAN"==i.tagName&&(i=i.previousSibling,delete k[i.innerText||i.textContent],setTimeout(n,0),t.removeChild(e))}function l(e){e&&(v.right=e&&!isNaN(e.right)?e.right:100,v.top=e&&!isNaN(e.top)?e.top:100),v.style.right=v.right+"px",v.style.top=v.top+"px"}function r(e){e.preventDefault(),e.stopPropagation();var t={right:v._right+v.x-e.pageX,top:v._top+e.pageY-v.y};l(t)}function u(){b.innerHTML=v.pin?"●":"○",b.setAttribute("title",v.pin?"固定在页面上":"固定在屏幕上"),v.style.position=v.pin?"absolute":""}function p(){i(),v.pin?v.top+=window.pageYOffset:v.top-=window.pageYOffset,u(),l(),a()}function c(){utils.addStyle("#ge_u{display:block;padding:10px;text-align:left;}#ge_u .ge_h{display:none;}#ge_u{z-index:10006;font:normal normal 400 12px/18px 宋体;position:fixed;}#ge_u>span{background:white;color:blue;border-radius:3px;border:1px solid #c0c0c0;padding:2px;cursor:pointer;}#ge_u>div{position:relative;margin-top:3px;}#ge_u>div>*{position:absolute;}.ge_u{background:white;border:1px solid silver;box-shadow:5px 5px 7px #333;}.ge_u{width:120px;max-height:400px;overflow-x:hidden;overflow-y:auto;}.ge_u>li{position:relative;display:block;padding:2px 20px 4px 6px;}.ge_u>li:hover{background:lightgray;}.ge_u a{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}.ge_u span{position:absolute;top:0;right:0;color:white;background:#77f;border-radius:3px;margin:2px;cursor:pointer;padding:2px;}"),v=document.createElement("div"),v.id="ge_u",v.innerHTML='<span>马甲<span></span></span><div><ul class="ge_u ge_h"></ul></div>',v.style.display=e("float",""),x=v.querySelector("ul"),x.onclick=s,b=v.firstChild.lastChild,v.pin=!!e("ge_pin"),u(),b.onclick=function(){t("ge_pin",v.pin=!v.pin),p()},v.onmouseover=function(e){this.contains(e.relatedTarget)||(x.classList.remove("ge_h"),x.style.pixelLeft=v.offsetLeft+v.firstChild.offsetLeft+x.offsetWidth<=document.body.offsetWidth?0:document.body.offsetWidth-v.offsetLeft-v.firstChild.offsetLeft-x.offsetWidth)},v.onmouseout=function(e){this.contains(e.relatedTarget)||x.classList.add("ge_h")};var o=e("ge_users_loc",{});"string"==typeof o&&(o=JSON.parse(o)),document.body.appendChild(v),l(o),v.moving=!1,v.firstChild.onmousedown=function(e){e.preventDefault(),e.stopPropagation(),e.target!=v.firstChild||v.moving||(v.moving=!0,i(),v.x=e.pageX,v.y=e.pageY,document.addEventListener("mousemove",r,!1))},v.onmouseup=function(e){v.moving&&(v.moving=!1,e.preventDefault(),e.stopPropagation(),document.removeEventListener("mousemove",r,!1),a())},f()}function f(){if(d=[],k){d.push("<li><a href=#>未登录状态</a></li>");for(var e in k)e?d.push("<li><a href=#>"+e.replace(/&/g,"&").replace(/</g,"<")+"</a><span>删</span></li>"):delete k[e]}else d.push('<li title="未检测到Cookie,请任意添加一个马甲或自行去除对应Cookie的HttpOnly属性。" style="color:gray">未检测到Cookie</li>');d.push("<li><a href=#>添加马甲</a></li>"),x.innerHTML=d.join("")}function g(){utils.popup.show({html:x.innerHTML,className:"ge_u",init:function(e){x.style.display="none",e.onclick=s},dispose:function(e){x.style.display="",e.onclick=null,f()}})}function h(){utils.popup.show({html:"<h3>设置 - 百度马甲切换脚本</h3><label><input type=checkbox id=gu_showfloat>显示悬浮图标</label><br><label>切换马甲快捷键:"+utils.getLink("hotkey",{title:"帮助",html:"(?)"})+'<input id=gu_shortcut></label><br><fieldset><legend>马甲数据 <button id=gu_import>导入</button> <button id=gu_export>导出</button> <a title="复制数据到以下文本框然后点击导入即可导入数据。\n点击导出后复制数据文本即可用于导入。">(?)</a></legend><textarea id=gu_data></textarea></fieldset>',className:"ge_opt",init:function(o){var i=o.querySelector("#gu_showfloat");i.checked="none"!=e("float"),i.onchange=function(){v.style.display=this.checked?"":"none",t("float",v.style.display)},i=o.querySelector("#gu_shortcut"),i.value=S,i.onchange=function(){S&&utils.shortcut(S),S=this.value,m(),t("shortcut",S)},i=o.querySelector("#gu_data"),i.onclick=function(){this.select()},o.querySelector("#gu_import").onclick=function(e){try{e=JSON.parse(i.value)}catch(t){e=null}if(e&&"object"==typeof e){for(var o in e)k[o]=e[o];n(),f(),alert("导入成功!")}else alert("导入失败!")},o.querySelector("#gu_export").onclick=function(){i.value=JSON.stringify(k)}}})}function m(){S&&utils.shortcut(S,g)}function _(t,o){k=e("ge_users",{}),S=e("shortcut","s-m"),(t=PageData)&&t.user&&t.user.is_login&&t.user.name?t=t.user.name:(t=unsafeWindow.s_session)&&(t=t.username),t&&(o=document.cookie.match(/BDUSS=(.*?)(;|$)/),o?(k[t]=o[1],n()):k=null),GM_registerMenuCommand("百度马甲设置",h),c(),m()}var y,v,x,b,w,k,S;window.top===window&&document.head&&_(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Tieba Advanced | |
// @namespace http://gera2ld.blog.163.com/ | |
// @author Gerald <[email protected]> | |
// @version 2.7.5.1 | |
// @description 贴吧增强 - Gerald倾情打造 | |
// @homepage http://userscripts.org:8080/scripts/show/152918 | |
// @include http://tieba.baidu.com/* | |
// @exclude http://tieba.baidu.com/tb/* | |
// @require https://greasyfork.org/scripts/1046-tieba-common/code/Tieba_Common.js | |
// ==/UserScript== | |
var mask=$('<div class=ge_mask style="padding:100px 100px 20px;">').appendTo('body'); // Mask layer | |
// Arrays for Lzl initiation | |
var lzl_init=[],lzl_buttons=[],lzl_styles=[],lzl_efilters=[]; | |
addPButton=function(o,c,m,a) { // 新增楼中楼按钮 | |
lzl_styles=lzl_styles.concat(c);o.addClass(c[0]); | |
if(!a) a={};if(!a.after) a.after='.lzl_panel_submit'; | |
lzl_buttons.push([o,m,a]); | |
return o; | |
}; | |
DELAY=2000; | |
// 初始化贴子管理面板 | |
function initPostManager() { | |
if(utils.postManager) return; | |
utils.addStyle('\ | |
#ge_tm{display:none;border-collapse:separate;width:100%;height:100%;background:white;color:#333;padding:20px;border-radius:20px;shadow:0 1px 5px #333;border-spacing:5px;table-layout:fixed;}\ | |
#ge_tm tr{height:1px;}\ | |
#ge_tm tr.ge_td{height:auto;}\ | |
.ge_td>td{width:50%;height:100%;vertical-align:top;position:relative;}\ | |
.ge_td>td>*{width:100%;height:100%;border:1px solid;overflow:auto;background:transparent;'+(window.opera?'position:absolute;':'')+'}\ | |
'); | |
var tm=$('<table id=ge_tm>').appendTo(mask); | |
tm.listItems=function(t,e,x,s){ | |
var d=[]; | |
if(x) d.push('<option>'+x+'</option>'); | |
t.list.forEach(function(i){d.push('<option>'+i.name+'</option>');}); | |
e.html(d.join('')); | |
if(s) {x=x?1:0;t.load(s-x);e.prop('selectedIndex',t.last+x);} | |
}; | |
tm.newItem=function(e,d) { | |
tm.list.load(tm.list.length-1); | |
if(!tm.list.cur||tm.list.cur.data) { | |
tm.list.load(tm.list.push(d)); | |
$('<option>').appendTo(ti).text(tm.list.cur.name); | |
} else { | |
tm.list.cur.type=d.type; | |
tm.list.cur.data=d.data; | |
} | |
$(ti).prop('selectedIndex',tm.list.last); | |
editItem(); | |
}; | |
var th=document.createElement('p'),tk='innerText' in th?'innerText':'textContent'; | |
function h2t(h){ // html to text | |
th.innerHTML=h.replace(/<br>/g,'\n'); | |
return th[tk]; | |
} | |
function t2h(t){ // text to html | |
th[tk]=t; | |
return th.innerHTML.replace(/ /g,' ').replace(/(^| ) /g,' $1').replace(/\r?\n/g,'<br>'); | |
} | |
function editItem(e) { | |
if(e) tm.list.load(ti.prop('selectedIndex'),1); | |
var t=tm.list.cur; | |
tc.prop('disabled',!t); | |
if(!t) t={type:'s',data:''}; | |
tt.val(t.type); | |
if(['j','h','H'].indexOf(t.type)>=0) tc.val(t.data); | |
else tc.val(h2t(t.data)); | |
liveShow(); | |
} | |
function saveItem(e) { | |
var t=tm.list.cur;if(!t) return; | |
switch(t.type=tt.val()) { | |
case 'j':try{eval(t.data=tc.val());}catch(e){}break; | |
case 's':t.data=t2h(tc.val());break; | |
case 'H':t.data=tc.val();break; | |
default:tv.find('img').each(function(i,e){ | |
e.setAttribute('pic_type',1); | |
unsafeWindow.EditorUI.resizeImage(e,560); | |
}); | |
tc.val(t.data=tv.html()); | |
} | |
} | |
function liveShow(e) { | |
function show() { | |
if(--count) return; | |
var t=tt.val(),s; | |
if(t=='j') try{s=eval(tc.val());}catch(e){s='<font color=red>JS代码有误!</font>';} | |
else s=tc.val(); | |
if(t=='s') s=t2h(s); | |
else if(t=='H') s=s.split('\n').shift(); | |
tv.html(s); | |
} | |
count++; | |
setTimeout(show,500); | |
} | |
var count=0; | |
tm.loadPanel=function(t,n,c) { | |
tm.list=t;tn.text(n);tm.callback=c; | |
tm.listItems(t,ti);editItem(1); | |
mask.fadeIn('fast',function() { | |
tm.css({display:'table'}).animate({top:'0px',left:'0px'},300); | |
}); | |
}; | |
var c=$('<td colspan=2>').appendTo($('<tr>').appendTo(tm)), | |
tn=$('<strong class=ge_rsep>').appendTo(c), | |
ti=$('<select>').appendTo(c).change(editItem); | |
$('<span class="ge_sbtn ge_rsep">改名</span>').appendTo(c).click(function(e) { | |
if(!tm.list.cur) return; | |
var t=prompt('修改名称:',tm.list.cur.name); | |
if(t) {tm.list.cur.name=t;ti.children('option:eq('+tm.list.last+')').text(t);} | |
}); | |
var tt=$('<select>').appendTo($('<label class=ge_rsep>类型:'+utils.getLink('advanced',{title:'帮助',html:'(?)'})+'</label>').appendTo(c)).html('<option value="s" checked>普通字串</option><option value="h">HTML代码</option><option value="H">HTML随机</option><option value="j">JS代码</option>').change(liveShow).blur(saveItem); | |
$('<span class=ge_sbtn>添加</span>').appendTo(c).click(tm.newItem); | |
$('<span class=ge_sbtn>删除</span>').appendTo(c).click(function() { | |
var l=tm.list.last;tm.list.pop(l);ti.children().eq(l).remove();editItem(1); | |
}); | |
c=$('<div style="float:right;"></div>').appendTo(c); | |
$('<span class=ge_sbtn>关闭</span>').appendTo(c).click(function() { | |
tm.list.save();if(tm.callback) tm.callback(); | |
tm.animate({top:innerHeight+'px'},300,function() {$(this).hide();mask.fadeOut('fast');}); | |
}); | |
$('<tr><td>编辑框</td><td align=right>预览框</td></tr>').appendTo(tm); | |
c=$('<tr class=ge_td>').appendTo(tm); | |
var tc=$('<textarea>').appendTo($('<td>').appendTo(c)).blur(saveItem).keyup(liveShow).mouseup(liveShow); | |
var tv=$('<div>').appendTo($('<td>').appendTo(c)); | |
utils.postManager=tm; | |
} | |
// 灌水 | |
function initAddWater(editor) { | |
initPostManager(); | |
var tails=utils.list('tails',null,function(){return {type:'s',data:'',name:'新尾巴'};},[ | |
{type:'j',name:'UA',data:'"——我喂自己袋盐<br>>>"+navigator.userAgent'}, | |
{type:'h',name:'求妹纸',data:'<img pic_type="1" class="BDE_Image" src="http://imgsrc.baidu.com/forum/w%3D580/sign=6ca77dcee5dde711e7d243fe97edcef4/b03533fa828ba61e111605e44134970a314e5905.jpg" width="560" height="11"><br><img pic_type="1" src="http://static.tieba.baidu.com/tb/editor/images/tsj/t_0010.gif" class="BDE_Smiley" height="40" width="40">求妹纸~'}, | |
]).load(),water=utils.list('water',null,function(){return {type:'s',data:'',name:'新水贴'};},[ | |
{type:'s',name:'打酱油',data:'我是打酱油的~'}, | |
]).load(); | |
function initTails(){utils.postManager.listItems(tails,ti,'随机',utils.getObj('tailindex',1));} | |
function initWater(){utils.postManager.listItems(water,wi,'随机',utils.getObj('waterindex',0));} | |
function getItem(t,s){ | |
var l=s.prop('selectedIndex'),L=t.length;if(!L) return; | |
if(!l) l=Math.floor(Math.random()*L); else l--; | |
t=t.list[l];var d=t.data; | |
if(t.type=='j') d=eval(d); | |
else if(t.type=='H') {d=d.split('\n');d=d[Math.floor(Math.random()*d.length)];} | |
return d; | |
} | |
var op=utils.addPopup($('#tb_rich_poster'),utils.addSButton('灌 水')).panel; | |
$('<div class=ge_sbtn style="cursor:default">智能灌水</div>').appendTo(op); | |
var ti=$('<select class=ge_rsep>').appendTo($('<label>尾巴:</label>').appendTo(op)).change(function(e){utils.setObj('tailindex',this.selectedIndex);}); | |
$('<br>').appendTo(op); | |
var tail=utils.bindProp($('<input type=checkbox>').prependTo($('<label class=ge_rsep>自动附加尾巴</label>').appendTo(op)),'checked','usetail',true); | |
$('<br>').appendTo(op); | |
$('<span class=ge_sbtn>存为新尾巴</span>').appendTo(op).click(function(e){ | |
utils.postManager.loadPanel(tails,'尾巴管理',initTails); | |
utils.postManager.newItem(e,{type:'h',name:'新尾巴',data:editor.$body.html()}); | |
}); | |
$('<span class=ge_sbtn>管理</span>').appendTo(op).click(function(e){utils.postManager.loadPanel(tails,'尾巴管理',initTails);}); | |
$('<hr>').appendTo(op); | |
var wi=$('<select class=ge_rsep>').appendTo($('<label>水贴:</label>').appendTo(op)).change(function(e){utils.setObj('waterindex',this.selectedIndex);}); | |
$('<br>').appendTo(op); | |
$('<span class=ge_sbtn>存为新水贴</span>').appendTo(op).click(function(e){ | |
utils.postManager.loadPanel(water,'水贴管理',initWater); | |
utils.postManager.newItem(e,{type:'h',name:'新水贴',data:editor.$body.html()}); | |
}); | |
$('<span class=ge_sbtn>管理</span>').appendTo(op).click(function(e){utils.postManager.loadPanel(water,'水贴管理',initWater);}); | |
$('<br>').appendTo(op); | |
$('<span class=ge_sbtn>载入</span>').appendTo(op).click(function(e){ | |
editor.execCommand('inserthtml',getItem(water,wi)); | |
}); | |
$('<span class=ge_sbtn>发表</span>').appendTo(op).click(function(e){ | |
editor.$body.html(getItem(water,wi)); | |
unsafeWindow.test_poster.post(); | |
}); | |
/*$('<span class=ge_sbtn>人工置顶</span>').appendTo(op).click(function(e){ | |
function post(){PostHandler.post(rich_postor._option.url,b,delay,function(){});} | |
function delay(m){ | |
if(m) { | |
if(m.no) d+=1000; else {d=DELAY;e.text('停止('+(++c)+')');} | |
} | |
if(!m||!m.no) b.content=getItem(water,wi); | |
setTimeout(post,d); | |
} | |
(e=$(this)).unbind('click').text('停止').click(function(){location.reload();}); | |
var c=0,d=0;b=rich_postor._getData();delay(); | |
});*/ | |
var tailed=false; | |
utils.hook(unsafeWindow.test_poster,'post',{before:function(){ | |
var t=getItem(tails,ti); | |
if(!tail.prop('checked')||!t||tailed) return; | |
editor.$body.append(' <br><br>'+t);tailed=true; // 加个空格以免破坏@ | |
}}); | |
initTails();initWater(); | |
} | |
// 尾页直达功能 | |
function initLastPage() { | |
utils.addStyle('.threadlist_rep_num{cursor:pointer;}'); | |
$('.threadlist_rep_num').prop('title','直达尾页').click(function(e){ | |
e=$(e.target);e.unbind('click'); | |
var s='',d=JSON.parse(e.parents('.j_thread_list').attr('data-field')); | |
setInterval(function(){ | |
if(s.length>2) s=''; else s+='.'; | |
e.html(s); | |
},300); | |
d='/p/'+d.id; | |
$.get(d,function(data){ | |
var m=data.match(/共<span class="red">(\d+)/)[1]; | |
if(m=='1') m=''; else m='?pn='+m; | |
location.href=d+m; | |
}); | |
}); | |
} | |
// 召唤术增强 | |
var calllist=utils.list('calllist','calllast',function(){return {name:'新列表',data:[]};},true).load(), | |
purl='http://imgsrc.baidu.com/forum/pic/item/fcb4c3fdfc039245664e092a8594a4c27c1e2592.jpg'; | |
function initCard() { | |
function fix(){ | |
var t=this._j_card,c=calllist.cur.data; | |
setTimeout(function(){ | |
function updateCSS(e) {e.css('background-position',j<0?'0 0':'-62px 0');} | |
var u=t.getData().un,j=c.indexOf(u),w=t.find('.interaction_wrap'),a; | |
if(w.length) updateCSS(a=$('<a href=# style="background:url('+purl+') no-repeat scroll 0 0">').appendTo(w).click(function(e){ | |
e.preventDefault(); | |
if(j<0) {j=c.length;c.push(u);} | |
else {for(;j<c.length-1;j++) c[j]=c[j+1];c.pop();j=-1;} | |
calllist.save(); | |
updateCSS(a); | |
})); | |
},0); | |
} | |
unsafeWindow._.Module.use("ihome/widget/UserVisitCard",{},function(b){ | |
utils.hook(b.__proto__,'buildVisitCard',{before:function(){ | |
utils.hook(this._visit_card,'setContent',{after:fix}); | |
}}); | |
}); | |
} | |
function initCall(editor) { | |
var pl,sl,be,bs,c=calllist; | |
utils.addStyle('\ | |
#callList{border:1px solid;height:125px;overflow:auto;background:white;width:380px;margin:0 auto;}\ | |
#callList a{padding:2px;border-radius:2px;margin:2px;display:inline-block;}\ | |
#callList a.selected{background:limegreen;color:white}\ | |
.edui-btn-toolbar .edui-btn .call_list,.lzl_panel_call{background:url("'+purl+'") no-repeat scroll transparent -124px 0;width:21px;}\ | |
.lzl_panel_call{height:20px;width:22px;float:right;}\ | |
'); | |
function newList(e) { | |
c.load(c.push());$('<option>').appendTo(sl).text(c.cur.name); | |
sl.prop('selectedIndex',c.last); | |
editList(e); | |
} | |
function editList(e) { | |
if(e) c.load(sl.prop('selectedIndex')); else sl.prop('selectedIndex',c.last); | |
pl.empty(); | |
c.cur.data.forEach(function(i){$('<a href=#>').html(i).appendTo(pl);}); | |
pl.prop('contenteditable',false); | |
} | |
function loadLists(p) { | |
var op=p.panel; | |
c.load();op.empty(); | |
$('<div class=ge_sbtn style="cursor:default">超级召唤</div>').appendTo(op); | |
sl=$('<select>').appendTo($('<label>选择名单:</label>').appendTo(op)).change(editList); | |
$('<span class="ge_sbtn ge_rsep">改名</span>').appendTo(op).click(function(e) { | |
e.preventDefault(); | |
var t=prompt('列表名称:',c.cur.name); | |
if(t) {sl.children(':eq('+c.last+')').text(t);c.cur.name=t;c.save();} | |
}); | |
$('<span class=ge_sbtn>新建列表</span>').appendTo(op).click(newList); | |
$('<span class="ge_sbtn ge_rsep">删除列表</span>').appendTo(op).click(function(e){ | |
e.preventDefault(); | |
var l=c.last;c.pop(l);editList();sl.children().eq(l).remove(); | |
}); | |
pl=$('<div id=callList>').appendTo(op).click(function(e){ | |
e.preventDefault(); | |
e=e.target;if(e.tagName=='A') $(e).toggleClass('selected'); | |
}).dblclick(function(e){ | |
e.stopPropagation(); | |
var s=window.getSelection(); | |
if(!s.rangeCount) return; | |
var r=s.getRangeAt(0),c=r.startContainer,k=r.startOffset; | |
var i=c.data.substr(0,k).search(/\s\S*$/),j=c.data.substr(k).search(/\s/); | |
r.setStart(c,i+1);r.setEnd(c,j<0?c.data.length:k+j); | |
s.removeAllRanges();s.addRange(r); // Compatible with Chrome | |
}); | |
$('<label>名单管理:</label>').appendTo(op); | |
be=$('<span>').appendTo(op); | |
$('<span class=ge_sbtn>编辑</span>').appendTo(be).click(function(e){ | |
bs.show();be.hide(); | |
pl.prop('contenteditable',true); | |
pl.text(c.cur.data.join(' ')); | |
}); | |
$('<span class=ge_sbtn>全选/不选</span>').appendTo(be).click(function(e){ | |
e.preventDefault(); | |
var a=pl.children('a:not(.selected)'); | |
if(a.length) a.addClass('selected'); else pl.children('a').removeClass('selected'); | |
}); | |
bs=$('<span>').appendTo(op).hide(); | |
$('<span class=ge_sbtn>去重</span>').appendTo(bs).click(function(e){ | |
var d=pl.text().replace(/^\s+|\s+$/,'').split(/\s+/),h={}; | |
d.forEach(function(i){h[i]=0;}); | |
pl.text(Object.getOwnPropertyNames(h).join(' ')); | |
}); | |
$('<span class="ge_sbtn ge_rsep">完成</span>').appendTo(bs).click(function(e){ | |
c.cur.data=pl.text().replace(/^\s+|\s+$/,'').split(/\s+/); | |
c.save();editList(e);be.show();bs.hide(); | |
}); | |
$('<span>空格隔开,双击选中一个名字</span>').appendTo(bs); | |
var b=$('<div style="float:right">').appendTo(op);be=be.add(b); | |
$('<span class=ge_sbtn title="普通召唤,超过十个ID将会失败">召唤</span>').appendTo(b).click(function(e){ | |
var se=p.holder==E?editor:unsafeWindow.LzlEditor._s_p._se; | |
pl.children('a.selected').each(function(i,e){se.execCommand('inserthtml','@'+e.innerHTML+' ');}); | |
p.onclose(); | |
}); | |
/*$('<span class=ge_sbtn title="插入一个占位符,将自动替换成召唤名单">自动召唤</span>').appendTo(b).click(function(e){ | |
e=[];pl.children('a.selected').each(function(){e.push(this.innerHTML);}); | |
p.onclose(); | |
if(e.length) { | |
p.holder.names=e; | |
e=p.holder==E?editor:unsafeWindow.LzlEditor._s_p._se; | |
e.execCommand('inserthtml','<img class=BDE_Smiley title="将在此自动插入召唤名单" alt="召唤列表" height=18>'); | |
} | |
});*/ | |
c.list.forEach(function(i){$('<option>').text(i.name).appendTo(sl);}); | |
editList(); | |
} | |
var l=/<img [^>]*?alt="召唤列表"[^>]*>/; | |
function addNames(e,n){ | |
if(n.splice) n='@'+n.splice(0,10).join(' @')+' '; | |
return e.replace(l,n); | |
} | |
// 主编辑框 | |
var o=utils.addTButton($('<div unselectable="on" class="edui-icon call_list" title="召唤">')); | |
var E=o.parents('.edui-toolbar'); | |
utils.addPopup(E,o,loadLists); | |
/*utils.hook(unsafeWindow.PostHandler,'post',{before:function(f,a){ | |
function post(){f.hook_func(a[0],a[1],E.names?delay:a[2],a[3]);} | |
function delay(m){ | |
if(m){if(m.no) d+=1000; else d=DELAY;} | |
if((!m||!m.no)&&E.names) { | |
a[1].content=addNames(e,E.names); | |
if(!E.names.length) delete E.names; | |
} | |
setTimeout(post,d); | |
} | |
var e=a[1].content,d=0;f.hookStop(); | |
if(E.names&&e.search(l)<0) delete E.names; | |
delay(); | |
}});*/ | |
// 楼中楼 | |
/*lzl_init.push(function(){ | |
utils.hook(unsafeWindow.SimplePostor.prototype,'_submitData',{before:function(f){ | |
function post(){ | |
$.tb.post(FORUM_POST_URL.postAdd,b,delay); | |
} | |
function delay(m){ | |
if(o.names) { | |
if(m){if(m.no) d+=1000; else d=DELAY;} | |
if(!m||!m.no) { | |
b.content=addNames(a,o.names); | |
if(!o.names.length) delete o.names; | |
} | |
setTimeout(post,d); | |
} else location.reload(); | |
} | |
if(o.names&&this._se.editArea.innerHTML.search(l)>=0) { | |
f.hookStop();var d=0,b=this._getData(),a=b.content;delay(); | |
} | |
}}); | |
});*/ | |
o=$('<span title="召唤">'); | |
addPButton(o,['lzl_panel_call'],utils.addPopup(o,null,loadLists).ontoggle,{keys:['click']}); | |
} | |
// 自动获取礼包 | |
// 来源:http://userscripts.org/scripts/show/268885 | |
// 感谢 Star Brilliant <[email protected]> | |
function initFetchGift() { | |
setInterval(function(){ | |
$('.rand_gift').click(); | |
$('.time_gift.unopen_gift').click(); | |
},10000); | |
} | |
// 字体颜色初始化 | |
function initFont() { | |
utils.colors={red:'#e10602'}; | |
utils.switchColor=function(cr,cs) { | |
document.execCommand('forecolor',false,document.queryCommandValue('forecolor').replace(/\s/g,'')==cr?'#333333':cs); | |
} | |
function fix() { | |
$(this.editArea).find('font[color]').each(function(i,e){ | |
e=$(e);i=e.html(); | |
switch(e.prop('color')){ | |
case utils.colors.red: | |
e.replaceWith('<span class="edit_font_color">'+i+'</span>'); | |
break; | |
} | |
}).end().find('b').each(function(i,e){ | |
e=$(e);i=e.html();e.replaceWith('<strong>'+i+'</strong>'); | |
}).end().find('span.at').each(function(i,e){ // allow at | |
e.outerHTML=e.innerHTML; | |
}); | |
} | |
var p=unsafeWindow.TED.EditorCore.prototype; | |
p.submitValidHTML=p.submitValidHTML.concat(['span','strong']); // allow font in Lzl | |
utils.hook(unsafeWindow.rich_postor._editor,'filteSubmitHTML',{before:fix}); | |
lzl_efilters.push(fix); | |
} | |
// 修复楼中楼定位翻页 | |
function initLzlFix() { | |
$('li.lzl_li_pager').each(function(i,e){ | |
if((e=$(e)).children('.lzl_more:hidden').length) e.children('.j_pager:hidden').show(); | |
}); | |
} | |
// 楼中楼初始化 | |
function initLzL() { | |
// 倒序添加按钮 | |
var t=$('#edit_parent .tb-editor-toolbar'); | |
if(t.children('.font_color').length) | |
addPButton($('<span title="红字" unselectable="on"></span>'),['font_color'], | |
function(e){utils.switchColor('rgb(225,6,2)',utils.colors.red);},{before:'.lzl_panel_smile'}); | |
if(t.children('.font_strong').length) | |
addPButton($('<span title="加粗" unselectable="on"></span>'),['font_strong'], | |
function(e){document.execCommand('bold',false,'');},{before:'.lzl_panel_smile'}); | |
// 楼中楼初始化 | |
function fixLzl() { | |
var p=$('div.lzl_panel_btn');p.parent().css('width','50%').prev().css('width','50%'); | |
lzl_buttons.forEach(function(i){utils.addButton(p,i[0],i[1],i[2]);}); | |
} | |
t='.font_strong,.font_color{background:url("http://tb2.bdstatic.com/tb/editor/v2/font_style.png") no-repeat transparent;height:20px;width:22px;}.font_color{background-position:0 -20px;}'; | |
if(lzl_styles.length) t+='.'+lzl_styles.join(',.')+'{margin:2px 1px;float:right;}'; | |
utils.addStyle(t); | |
if(unsafeWindow.LzlEditor._s_p) fixLzl(); | |
lzl_init.forEach(function(i){i();}); | |
utils.hook(unsafeWindow.SimplePostor.prototype,'_buildNormalEditor',{after:fixLzl}); | |
utils.hook(unsafeWindow.TED.SimpleEditor.prototype,'filteSubmitHTML',{before:lzl_efilters}); | |
utils.hook(unsafeWindow.SimplePostor.prototype,'_getHtml',{before:function(f){ | |
f.hookStop();return this._se.getHtml(); | |
}}); | |
} | |
function fixer(func,args){ | |
try{func.apply(this,args);}catch(e){ | |
var f=$('<div>').appendTo('body').css({width:'120px',position:'fixed',left:0,top:0,display:'none','text-align':'center','z-index':999}); | |
$('<div>出错了!如需反馈请复制以上信息</div>').appendTo(f).css('color','white').add( | |
$('<a href=http://userscripts.org/scripts/discuss/152918>点此反馈</a>').appendTo(f).css('color','yellow') | |
).css({background:'purple',margin:'1px',padding:'10px','border-radius':'5px',display:'block'}); | |
var m=location.href+'\n'+e.name+': '+e.message+'\n'+(e.stacktrace||e.stack); | |
if(window.console) console.log(m); | |
f.prepend($('<textarea style="height:200px;">').val(m.slice(0,1024)).mouseover(function(e){this.select();})).show(); | |
} | |
} | |
function initEditor(editor){ | |
// 此模块仅在有输入框且允许发言时加载 | |
fixer(function(){ | |
initAddWater(editor); // 灌水+尾巴 | |
initCall(editor); // 召唤增强,召唤列表 | |
//initFont(editor); //初始化:高级字体 | |
}); | |
} | |
// 以下为模块调用,可将不需要的模块注释,不要改变顺序 | |
if($&&PageData&&PageData.user) { // 出错反馈按钮 | |
initCard(); // 用户卡片上添加召唤按钮 | |
// 以下模块无需登录 | |
if(PageData.thread) { // 以下模块仅在帖子浏览页面加载 | |
//initLzlFix(); // 修复楼中楼定位翻页 | |
} else { | |
initLastPage(); // 尾页直达功能 | |
} | |
//以下模块仅在登录时加载 | |
if(PageData.user.is_login) { | |
if(unsafeWindow.PosterContext&&unsafeWindow.PosterContext.isPostAllowed()) utils.wait(unsafeWindow,'test_editor',initEditor); | |
initFetchGift(); | |
if(unsafeWindow.LzlEditor&&unsafeWindow.SimplePostor) initLzL(); //初始化楼中楼:支持已加载的功能 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Tieba Float Movable | |
// @namespace http://gera2ld.blog.163.com/ | |
// @author Gerald <[email protected]> | |
// @version 1.2.8 | |
// @description 贴吧可移动悬浮窗 | |
// @homepage http://userscripts.org/scripts/show/156576 | |
// @include http://tieba.baidu.com/* | |
// @exclude http://tieba.baidu.com/tb/* | |
// @require https://greasyfork.org/scripts/1046-tieba-common/code/Tieba_Common.js | |
// @grant GM_getValue | |
// @grant GM_setValue | |
// @grant GM_registerMenuCommand | |
// ==/UserScript== | |
function t(t,e){var i={};args.forEach(function(t){i[t]=/^-?\d+px/.test(e[t])?e[t]:"20px"}),t.css(i)}function e(e,i){var o=$(e);o.mousedown&&(e.moving=!1,args=["right","bottom"],o.mousedown(function(n){["DIV","TD"].indexOf(n.target.tagName)<0||"true"==n.target.contentEditable||(n.preventDefault(),n.stopPropagation(),e.x=n.pageX,args.indexOf("left")>=0?e.x-=parseInt(o.css("left")):e.x+=parseInt(o.css("right")),e.y=n.pageY,args.indexOf("top")>=0?e.y-=parseInt(o.css("top")):e.y+=parseInt(o.css("bottom")),e.moving||$(document).mousemove(function(i){if(e.moving){var n={};for(var l in args){var p=args[l];if("left"==p)n[p]=i.pageX-e.x;else if("right"==p)n[p]=e.x-i.pageX;else if("top"==p)n[p]=i.pageY-e.y;else{if("bottom"!=p)continue;n[p]=e.y-i.pageY}n[p]+="px"}t(o,n)}i.preventDefault()}).mouseup(function(){if(e.moving){e.moving=!1;var t={};for(var n in args){var l=args[n];t[l]=o.css(l)}utils.setObj("mcss_"+i,t),$(document).unbind("mousemove").unbind("mouseup")}}),e.moving=!0)}),t(o,utils.getObj("mcss_"+i,{})))}function i(t){$(t).unbind("mousedown").css({left:"",right:"",top:"",bottom:""})}unsafeWindow.PosterContext&&unsafeWindow.PosterContext.isPostAllowed()&&utils.wait(unsafeWindow,"test_editor",function(o){function n(){utils.unminify&&(k.hide(),b.show(),o.focus(),delete utils.unminify)}function l(){b.hide(),k.show(),utils.unminify=n}function p(){"normal"!=y&&x?m.html(".edui-popup{bottom:44px;top:auto !important;}.edui-popup-caret{bottom:-8px;top:auto !important;transform:scale(1,-1);}"):m.html("")}function r(t){if(t&&("dblclick"==t.type?y="open"==y?"close":"open":(y="normal"==y?"open":"normal",p()),utils.setObj("float",y)),!t||"click"==t.type){if("normal"==y)return c.html(""),u.html(""),g.html("<span><em>悬 浮</em></span>"),b.unbind("dblclick"),i(b[0]),b.prop("title",""),h.attr("style",f),O.hide(),void 0;c.html(d),g.html("<span><em>停 靠</em></span>"),v&&b.unbind("dblclick").dblclick(r),e(b[0],"float"),h.prop("style",""),w?(l(),O.show()):(n(),O.hide())}v&&"open"!=y?(u.html("#tb_rich_poster{width:360px;}#tb_rich_poster *{max-width:360px;}#ueditor_replace{min-height:24px !important;width:310px !important;}.poster_success{top:0 !important;left:40px !important;}.editor_bottom_panel,.edui-toolbar{display:none;}.editor_textfield{padding:0 !important;}.old_style_wrapper{width:330px !important;}"),b.attr("title","双击展开")):(u.html("#tb_rich_poster{width:635px;}#tb_rich_poster *{max-width:635px;}#ueditor_replace{min-height:50px !important;}.poster_success{top:50px !important}"),v&&b.attr("title","双击精简"))}function s(){utils.popup.show({html:'<h3>贴吧悬浮窗脚本设置</h3><label><input type=checkbox id=allowUp>编辑框中的弹出窗口向上弹出</label><br><label><input type=checkbox id=allowMinify>自动隐藏悬浮窗口到右下角</label><br><label style="margin-left:20px;">从右下角呼出快捷键:'+utils.getLink("hotkey",{title:"帮助",html:"(?)"})+'<input id=shortcut style="width:60px"></label><br><label><input type=checkbox id=allowSimple>双击悬浮窗口使其精简或展开</label><br><button id=btReset>重置悬浮窗位置</button>',className:"ge_opt",init:function(e){e.querySelector("#btReset").onclick=function(){t(b,{})},utils.bindProp($("#allowUp",e),"checked","allowUp",0,function(){x=this.checked,p()}),utils.bindProp($("#allowMinify",e),"checked","allowMinify",0,function(){w=this.checked}),utils.bindProp($("#shortcut",e),"value","hk-float",0,function(){_&&utils.shortcut(_),_=this.value,a()}),utils.bindProp($("#allowSimple",e),"checked","allowSimple",0,function(){v=this.checked})},dispose:function(){r()}})}function a(){_&&utils.shortcut(_,n)}var d="#tb_rich_poster{border:3px double grey;position:fixed !important;z-index:10001;background-color:#E7EAEB;}#tb_rich_poster .editor_wrapper{margin-left:2px;}.poster_head,#bdInputObjWrapper,.tb_poster_placeholder,.poster_signature,.poster_draft_status,.poster_reply{display:none !important;}#tb_rich_poster,.editor_bottom_panel{margin-bottom:0 !important;}#tb_rich_poster,.poster_body,.poster_component{padding:0 !important;}",u=utils.addStyle(),c=utils.addStyle(),m=utils.addStyle(),h=o.$body,b=$("#tb_rich_poster"),f=h.attr("style"),g=utils.addSButton().click(r),_=utils.getObj("hk-float",""),y=utils.getObj("float","normal"),x=utils.getObj("allowUp",!0),w=utils.getObj("allowMinify",!0),v=utils.getObj("allowSimple",!0),k=$('<div id=btUnminify style="position:fixed;bottom:0;right:0;background:white;padding-top:40px;z-index:10;">◀</div>').appendTo(document.body).hide().mouseover(n),O=$('<div style="position:absolute;border:1px solid gray;background:inherit;height:100%;cursor:pointer;right:0;" title="最小化">▶</div>').appendTo($('<div style="position:relative;background:inherit;height:100%;">').appendTo($('<div style="position:absolute;top:0;background:inherit;height:100%;">').appendTo(b))).hide().click(l);r(),p(),a(),GM_registerMenuCommand("悬浮窗设置",s),$(".j_quick_reply").click(n)}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Tieba Imagizer | |
// @namespace http://gera2ld.blog.163.com/ | |
// @author Gerald <[email protected]> | |
// @version 1.2.6 | |
// @description 贴吧图化 - Gerald倾情打造 | |
// @homepage http://userscripts.org/scripts/show/156579 | |
// @include http://tieba.baidu.com/* | |
// @exclude http://tieba.baidu.com/tb/* | |
// @require https://greasyfork.org/scripts/1046-tieba-common/code/Tieba_Common.js | |
// ==/UserScript== | |
function o(e){var o="http://static.tieba.baidu.com/tb/static-frs/component/sign_shai/flash_image_loader.js";unsafeWindow.FlashImageLoader?e():$.getScript(o,e)}function t(){if(!utils.colorInput){var e=document.createElement("input");if(e.setAttribute("type","color"),"color"==e.type)return utils.colorInput=function(e,o,t,a){return utils.bindProp($("<input type=color id="+e+' class="ge_rsep colorbox">'),"value",o,t,a,["change","keyup"])};utils.addStyle("#colors{display:none;position:absolute;background:white;border:2px ridge;padding:10px;cursor:default;}#colors .colors{width:261px;cursor:pointer;margin:2px;border-collapse:separate;border-spacing:1px;background:black;}#colors .colors td{display:table-cell !important;width:12px;height:12px;border:none;emptycells:show;}.colorbox{width:12px;height:12px;border:1px solid;display:inline-block;position:relative;top:3px;}");var o,t,a,i=$("<div id=colors>").click(function(e){e.stopPropagation()});o=function(e){var o=$(e.target).attr("data");o&&("mouseover"==e.type?(t&&t.css("outline","none"),t=$(e.target).css("outline","1px outset yellow"),$("#ge_vcolor").val(o)):i.owner.setColor(o))},a=$("<table class=colors>").appendTo(i).mouseover(o).click(o);for(var n=["00","33","66","99","cc","ff"],l=["#ffffff","#ff0000","#00ff00","#0000ff","#ffff00","#00ffff","#ff00ff"],e=0;12>e;e++){o=$("<tr>").appendTo(a),t=6>e?"#"+n[e]+n[e]+n[e]:l[e-6],$("<td>").appendTo(o).css({background:t}).attr("data",t),e||$('<td rowspan=12 style="background:white;">').appendTo(o);for(var r=0;18>r;r++)t="#"+n[3*Math.floor(e/6)+Math.floor(r/6)]+n[r%6]+n[e%6],$("<td>").appendTo(o).css({background:t}).attr("data",t)}a=$("<form>").appendTo(i),$('<span id=ge_scolor class="ge_rsep colorbox">').appendTo(a),o=function(){$("#ge_scolor").css("background",this.value)},$('<input type=text id=ge_vcolor style="width:60px" class=ge_rsep>').appendTo(a).change(o).keyup(o),o=function(e){e.preventDefault(),i.owner.setColor($("#ge_scolor").css("background-color"))},$("<span class=ge_sbtn>OK</span>").appendTo(a).click(o),a.submit(o),t=null,utils.colorInput=function(e,o,t,a){var n=$("<span id="+e+" class=colorbox>"),l=utils.getObj(o,t);return n.css({border:"1px outset white",cursor:"pointer",background:l}).attr("data",l).click(function(e){i.owner!=n?(i.owner=n,i.appendTo(n).css({top:"auto",bottom:"auto"}).show(),i.offset().top+i.height()>pageYOffset+innerHeight?i.css("bottom","14px"):i.css("top","14px"),$("#ge_scolor").css("background",e=n.attr("data")),$("#ge_vcolor").val(e)):(i.owner=null,i.hide())}),n.setColor=function(e){e=e.replace(/rgb\((\d+),\s?(\d+),\s?(\d+)\)/i,function(e,o,t,a){e=[o,t,a];for(o in e)e[o]=parseInt(e[o]).toString(16),e[o].length<2&&(e[o]="0"+e[o]);return"#"+e.join("")}),n.attr("data",e).css("background",e),utils.setObj(o,e),i.owner=null,i.hide(),a()},n[0].val=function(){return n.attr("data")},n[0]}}}function a(a){function l(){var e={},o=[];return $("#w2iitalic").prop("checked")&&o.push("italic"),$("#w2ibold").prop("checked")&&o.push("bold"),o.push($("#w2isize").val()+"px"),v.val()&&o.push(v.val()),e.font=o.join(" "),e.color=x.val(),e.background=$("#w2iabgclr").prop("checked")?k.val():"inherit",e}function r(){b&&(h.html(b),b=null,T.addClass("ge_disabled"))}function s(){o(function(){utils.uploadImage=function(e,o){function t(){alert("图片上传发生错误!"),r(),n()}function a(e,a){var i=JSON.parse(a);if(i.error_code)t();else{var l="http://imgsrc.baidu.com/forum/pic/item/"+i.info.pic_id_encode+".jpg";$(o).replaceWith('<img class="BDE_Image" src="'+l+'" pic_type="0" onload="EditorUI.resizeImage(this,560)">'),n()}}function i(){unsafeWindow.FlashImageLoader.bind("uploadComplete",a),unsafeWindow.FlashImageLoader.bind("uploadError",t)}function n(){unsafeWindow.FlashImageLoader.unbind("uploadComplete",a),unsafeWindow.FlashImageLoader.unbind("uploadError",t)}$.get("/dc/common/imgtbs",function(o){i(),unsafeWindow.FlashImageLoader.uploadBase64("http://upload.tieba.baidu.com/upload/pic",e.replace(/^data:.*?;base64,/,""),{tbs:o.data.tbs})},"json")},w.removeClass("ge_disabled").text("开始图化").unbind("click").click(c)})}function p(e){function o(e){e.parentNode.removeChild(e)}function t(e){for(var o=[e];e.parentNode!==a.body&&(e=e.parentNode);)o.unshift(e);return o}var i,n,l=e.startContainer,r=e.endContainer,s=e.startOffset,p=e.endOffset,d=e.document,c=d.createDocumentFragment();if(1==l.nodeType&&(l=l.childNodes[s]||(i=l.appendChild(d.createTextNode("")))),1==r.nodeType&&(r=r.childNodes[p]||(n=r.appendChild(d.createTextNode("")))),l===r&&3==l.nodeType)return c.appendChild(d.createTextNode(l.substringData(s,p-s))),l.deleteData(s,p-s),e.collapse(!0),c;for(var u,f,b=c,h=t(l),g=t(r),w=0;h[w]==g[w];)w++;for(var m,$=w;m=h[$];$++){for(u=m.nextSibling,m==l?i||(3==e.startContainer.nodeType?b.appendChild(d.createTextNode(l.nodeValue.slice(s))):b.appendChild(l)):(f=m.cloneNode(!1),b.appendChild(f));u&&u!==r&&u!==g[$];)m=u.nextSibling,b.appendChild(u),u=m;b=f}b=c,h[w]||(b.appendChild(h[w-1].cloneNode(!1)),b=b.firstChild);for(var v,$=w;v=g[$];$++){if(u=v.previousSibling,v==r?n||3!=e.endContainer.nodeType||(b.appendChild(d.createTextNode(r.substringData(0,p))),r.deleteData(0,p)):(f=v.cloneNode(!1),b.appendChild(f)),$!=w||!h[w])for(;u&&u!==l;)v=u.previousSibling,b.insertBefore(u,b.firstChild),u=v;b=f}return e.setStartBefore(g[w]?h[w]?g[w]:h[w-1]:g[w-1]).collapse(!0),i&&o(i),n&&o(n),c}function d(e){return $("<div>").append(e.childNodes||e.html()).html(function(e,o){return o.replace(/<br>(<\/p>)?|<\/p>/gi,"\n")}).text().replace(/\s+$/,"")}function c(){b=h.html(),T.removeClass("ge_disabled");var o=parseInt($("#w2isize").val()),t=$('<img title="双击撤销">').attr("src",n),r=a.selection.getRange(),s=null;if(r.collapsed||(s=d(p(r))),s&&/\S/.test(s))r.insertNode(t[0]);else{if(s=d(h),!/\S/.test(s))return;h.html(t)}var c=s.split("\n"),u=0,f=document.createElement("canvas"),g=f.getContext("2d"),w=Math.round(1.5*o),m=[];s=l(),g.font=s.font,c.forEach(function(e){e=e.replace(/\s+$/,"");do{for(var o=0,t=0;t<e.length&&(o+=g.measureText(e[t]).width,!(o>560));t++)o>u&&(u=o);m.push(e.substr(0,t)),e=e.substr(t)}while(e)}),f.height=w*m.length,f.width=u,$("#w2ishadow").prop("checked")&&(g.shadowColor="gray",g.shadowBlur=g.shadowOffsetY=g.shadowOffsetX=Math.ceil(o/25)),$("#w2iabgclr").prop("checked")&&(g.fillStyle=s.background,g.fillRect(0,0,u,f.height)),g.font=s.font,g.fillStyle=g.strokeStyle=s.color,e=$("#w2istroke").prop("checked")?g.strokeText:g.fillText,i=0,m.forEach(function(t){e.call(g,t,0,o+w*i++)}),utils.uploadImage(f.toDataURL(),t)}function u(e){e=l();var o,t="";for(o in e)e[o]+=" !important";$("#w2ipreview").prop("checked")?f.html("#ueditor_replace{font:"+e.font+";color:"+e.color+";background:"+e.background+"}"):f.html("");for(o in e)t+=o+":"+e[o]+";";v.css("cssText",t)}var f=utils.addStyle(),b=null,h=a.$body,g=utils.addPopup($("#tb_rich_poster"),utils.addSButton("图 化")).panel;utils.uploadImage=null;var w=$('<div class="ge_sbtn ge_disabled" style="margin:0 0 2px;">图化组件初始化失败,点击重试</div>').appendTo(g).click(s);s(),utils.addStyle("#w2iface{max-width:800px;max-height:400px;}");var m=utils.list("w2ifaces","w2ifaceid",null,["微软雅黑"]).load(),v=$("<select id=w2iface>").appendTo($("<label>字体:</label>").appendTo(g)).change(function(){m.load(v.prop("selectedIndex")),u()});m.list.forEach(function(e){$("<option>"+e+"</option>").appendTo(v)}),v.prop("selectedIndex",m.last),$("<span class=ge_sbtn>+</span>").appendTo(g).click(function(e){(e=prompt("请输入字体名称:"))&&(m.load(m.push(e)),$("<option>").text(e).appendTo(v),v.val(e),u())}),$("<span class=ge_sbtn>-</span>").appendTo(g).click(function(e){e=v.prop("selectedIndex"),v.children(":eq("+e+")").remove(),m.pop(e),m.load(v.prop("selectedIndex")),u()}),t();var x,k;utils.bindProp($("<input type=checkbox id=w2ipreview>").appendTo(g),"checked","w2ipreview",!1,u),$("<label for=w2ipreview>预览</label><br><label for=w2icolor>颜色:</label>").appendTo(g),$(x=utils.colorInput("w2icolor","w2icolor","#2222ff",u)).appendTo(g).addClass("ge_rsep"),$("<label for=w2isize>大小:</label>").appendTo(g),utils.bindProp($('<input type=number id=w2isize min=9 class=ge_rsep style="height:18px;width:40px;">').appendTo(g),"value","w2isize",22,u),utils.bindProp($("<input type=checkbox id=w2iabgclr>").appendTo(g),"checked","w2iabgclr",!1,u),$("<label for=w2iabgclr>背景色:</label>").appendTo(g),$(k=utils.colorInput("w2ibgclr","w2ibgclr","#efe4b0",u)).appendTo(g),$("<br>").appendTo(g),utils.bindProp($("<input type=checkbox id=w2ibold>").appendTo(g),"checked","w2ibold",!1,u),$("<label for=w2ibold class=ge_rsep>加粗</label>").appendTo(g),utils.bindProp($("<input type=checkbox id=w2iitalic>").appendTo(g),"checked","w2iitalic",!1,u),$("<label for=w2iitalic class=ge_rsep>倾斜</label>").appendTo(g),utils.bindProp($("<input type=checkbox id=w2ishadow>").appendTo(g),"checked","w2ishadow",!1,u),$("<label for=w2ishadow class=ge_rsep>阴影</label>").appendTo(g),utils.bindProp($("<input type=checkbox id=w2istroke>").appendTo(g),"checked","w2istroke",!1,u),$("<label for=w2istroke class=ge_rsep>镂空</label>").appendTo(g);var T=$('<span class="ge_sbtn ge_disabled" title="回到最后一次图化前的状态">撤销图化</span>').appendTo(g).click(r);v.prop("selectedIndex",m.last),u()}var n="http://tb2.bdstatic.com/tb/static-postor/images/loading_33e098e1.gif";unsafeWindow.PosterContext&&unsafeWindow.PosterContext.isPostAllowed()&&utils.wait(unsafeWindow,"test_editor",a); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Tieba Multiuser | |
// @namespace http://gera2ld.blog.163.com/ | |
// @author Gerald <[email protected]> | |
// @version 1.3.1.1 | |
// @description 百度贴吧马甲切换 | |
// @homepage http://userscripts.org/scripts/show/154072 | |
// @downloadURL https://userscripts.org/scripts/source/154072.user.js | |
// @updateURL https://userscripts.org/scripts/source/154072.meta.js | |
// @include http://tieba.baidu.com/* | |
/ @require https://greasyfork.org/scripts/1046-tieba-common/code/Tieba_Common.js | |
// @grant GM_getValue | |
// @grant GM_setValue | |
// @grant GM_registerMenuCommand | |
// ==/UserScript== | |
function e(e,t){var o=GM_getValue(e,"");return o&&"string"==typeof o&&(o=JSON.parse(o)),o||t}function t(e,t){GM_setValue(e,JSON.stringify(t))}function o(e,t){var o=new Date;e?o.setTime(16094e8):e="",document.cookie="BDUSS="+e+";domain=baidu.com;path=/;expires="+o.toGMTString(),"function"==typeof t?t():"string"==typeof t?location.replace(t):location.reload()}function n(){t("ge_users",s)}function i(e,t,i){e.preventDefault(),i=e.target,e=i.parentNode,t=e.parentNode,"A"==i.tagName?e==t.firstChild?o():e==t.lastChild?location.href="http://wappass.baidu.com/?login&u="+encodeURIComponent(location.href):o(s[i.innerText||i.textContent]):"SPAN"==i.tagName&&(i=i.previousSibling,delete s[i.innerText||i.textContent],setTimeout(n,0),t.removeChild(e))}function r(e){utils.addStyle("#ge_tu>li{position:relative;cursor:pointer;}#ge_tu span{position:absolute;top:0;right:0;background:#77f;color:white;border-radius:3px;border:1px solid;border:none;margin:2px;padding:2px;cursor:pointer;line-height:1em;}"),$("<li class=split>").prependTo(e);var t=$('<li><div class="u_menu_item"><a href=# class=u_menu_wrap style="margin-top:-2px;">马甲</a></div></li>').prependTo(e).mouseover(function(){o.show(),n.addClass("u_menu_hover")}).mouseout(function(){o.hide(),n.removeClass("u_menu_hover")}),o=$("<div class=u_ddl>").hide().appendTo(t),n=t.children().first();$('<div class=u_ddl_tit style="left:1px;">').appendTo(o).width(t.innerWidth()-2),c=$("<ul id=ge_tu>").appendTo($('<div class="u_ddl_con u_ddl_con_top">').appendTo(o)).click(i),a()}function a(){if(d=[],s){d.push("<li><a href=#>未登录状态</a></li>");for(var e in s)e?d.push("<li><a href=#>"+e.replace(/&/g,"&").replace(/</g,"<")+"</a><span>删</span></li>"):delete s[e]}else d.push('<li title="未检测到Cookie,请任意添加一个马甲或自行去除对应Cookie的HttpOnly属性。" style="color:gray">未检测到Cookie</li>');d.push("<li><a href=#>添加马甲</a></li>"),c.html(d.join(""))}function l(){utils.popup.show({html:'<h3>设置 - 贴吧马甲切换脚本</h3><fieldset><legend>马甲数据 <button id=gu_import>导入</button> <button id=gu_export>导出</button> <a title="复制数据到以下文本框然后点击导入即可导入数据。\n点击导出后复制数据文本即可用于导入。">(?)</a></legend><textarea id=gu_data></textarea></fieldset>',className:"ge_opt",init:function(e){var t=e.querySelector("#gu_data");t.onclick=function(){this.select()},e.querySelector("#gu_import").onclick=function(e){try{e=JSON.parse(t.value)}catch(o){e=null}if(e&&"object"==typeof e){for(var i in e)s[i]=e[i];n(),a(),alert("导入成功!")}else alert("导入失败!")},e.querySelector("#gu_export").onclick=function(){t.value=JSON.stringify(s)}}})}function u(t,o){function i(e){"com_userbar"==e.target.parentNode.id&&(document.body.removeEventListener("DOMNodeInserted",i,!1),r(e.target))}s=e("ge_users",{}),(t=PageData)&&t.user&&t.user.is_login&&t.user.name&&(t=t.user.name),t&&(o=document.cookie.match(/BDUSS=(.*?)(;|$)/),o?(s[t]=o[1],n()):s=null),GM_registerMenuCommand("贴吧马甲设置",l),document.body.addEventListener("DOMNodeInserted",i,!1)}var s,c;document.querySelector("a[param=word]")&&u(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment