// ==UserScript== // @name Tieba Multiuser // @namespace http://gera2ld.blog.163.com/ // @author Gerald // @icon http://s.gravatar.com/avatar/a0ad718d86d21262ccd6ff271ece08a3?s=80 // @version 1.3 // @description 百度贴吧马甲切换 // @homepage http://userscripts.org/scripts/show/154072 // @include http://tieba.baidu.com/* // @require http://userscripts.org/scripts/source/186749.user.js // @grant GM_getValue // @grant GM_setValue // @grant GM_registerMenuCommand // @downloadURL none // ==/UserScript== function e(e,t){var n=GM_getValue(e,"");return n&&"string"==typeof n&&(n=JSON.parse(n)),n||t}function t(e,t){GM_setValue(e,JSON.stringify(t))}function n(e,t){var n=new Date;e?n.setTime(16094e8):e="",document.cookie="BDUSS="+e+";domain=baidu.com;path=/;expires="+n.toGMTString(),"function"==typeof t?t():"string"==typeof t?location.replace(t):location.reload()}function o(){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?n():e==t.lastChild?location.href="http://wappass.baidu.com/?login&u="+encodeURIComponent(location.href):n(s[i.innerText||i.textContent]):"SPAN"==i.tagName&&(i=i.previousSibling,delete s[i.innerText||i.textContent],setTimeout(o,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;cursor:pointer;text-align:center;padding:0 2px;}");var t=document.createElement("li"),n=document.createElement("li");e.insertBefore(t,e.firstChild),t.className="split",e.insertBefore(n,t),n.innerHTML="马甲",n.onmouseover=function(){t.style.display="block"},n.onmouseout=function(){t.style.display="none"},t=document.createElement("div"),n.appendChild(t),t.className="u_ddl",t.setAttribute("style","display:none;width:40px;top:-2px;"),e=document.createElement("div"),t.appendChild(e),e.className="u_ddl_con u_ddl_con_top",c=document.createElement("ul"),e.appendChild(c),c.id="ge_tu",c.onclick=i,a()}function a(){if(d=[],s){d.push("
  • 未登录状态
  • ");for(var e in s)e?d.push("
  • "+e.replace(/&/g,"&").replace(/
  • "):delete s[e]}else d.push('
  • 未检测到Cookie
  • ');d.push("
  • 添加马甲
  • "),c.innerHTML=d.join("")}function l(){utils.popup.show({html:'

    设置 - 贴吧马甲切换脚本

    马甲数据 (?)
    ',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(n){e=null}if(e&&"object"==typeof e){for(var i in e)s[i]=e[i];o(),a(),alert("导入成功!")}else alert("导入失败!")},e.querySelector("#gu_export").onclick=function(){t.value=JSON.stringify(s)}}})}function u(t,n){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&&(n=document.cookie.match(/BDUSS=(.*?)(;|$)/),n?(s[t]=n[1],o()):s=null),GM_registerMenuCommand("贴吧马甲设置",l),document.body.addEventListener("DOMNodeInserted",i,!1)}var s,c;document.querySelector("a[param=word]")&&u();