Tieba Common

Common JS for Baidu scripts by Gerald

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/144/35452/Tieba%20Common.js

  1. // ==UserScript==
  2. // @name Tieba Common
  3. // @namespace http://geraldl.net/
  4. // @author Gerald <gera2ld@163.com>
  5. // @description Common JS for Baidu scripts by Gerald
  6. // @version 1.0
  7. // ==/UserScript==
  8.  
  9. if(typeof unsafeWindow=='undefined') unsafeWindow=window;
  10. var $=unsafeWindow.$,PageData=unsafeWindow.PageData,utils=null,
  11. gkey='__ge_firefox';
  12. (function(){
  13. function getObj(key,def){
  14. var v=ff[key];
  15. if(v==null&&def!=null) setObj(key,v=def);
  16. return v;
  17. }
  18. function setObj(key,val){ff[key]=val;}
  19. function notice(title,msg){
  20. var n=getObj('msg',{});
  21. if(!n[title]) {
  22. n[title]=1;
  23. var d=document.createElement('div');
  24. d.setAttribute('style','position:fixed;z-index:999999;background:white;border:1px solid;border-radius:3px;padding:10px;top:50px;left:50px;');
  25. d.innerHTML='<a href=# style="float:right">关闭</a><h3 style="margin-right:2.5em;">'+title+'</h3>'+msg;
  26. document.body.appendChild(d);
  27. d.firstChild.onclick=function(e){
  28. e.preventDefault();d.parentNode.removeChild(d);
  29. };
  30. return d;
  31. }
  32. }
  33. var ff=unsafeWindow[gkey];
  34. if(!ff) ff=unsafeWindow[gkey]={};
  35. utils=getObj('utils');
  36. if(!utils)
  37. notice('未检测到依赖脚本!','请确认已安装并启用:<br><a target=_blank href=https://greasyfork.org/scripts/118>Tieba Utilities</a><br><p align=right>——寂寞的原子</p>');
  38. })();