Tieba Common

Common JS for Baidu scripts by Gerald

目前為 2014-07-13 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/144/9622/Tieba%20Common.js

// ==UserScript==
// @name	Tieba Common
// @namespace	http://gera2ld.blog.163.com/
// @author	Gerald <[email protected]>
// @description	Common JS for Baidu scripts by Gerald
// ==/UserScript==

var $=unsafeWindow.$,PageData=unsafeWindow.PageData,utils=null;
(function(){
function getObj(key,def){
	var v=(ff||window)[key];
	if(v==null&&def!=null) setObj(key,v=def);
	return v;
}
function setObj(key,val){(ff||window)[key]=val;}
function notice(title,msg){
	var n=getObj('msg',{});
	if(!n[title]) {
		n[title]=1;
		var d=document.createElement('div');
		d.setAttribute('style','position:fixed;z-index:999999;background:white;border:1px solid;border-radius:3px;padding:10px;top:50px;left:50px;');
		d.innerHTML='<a href=# style="float:right">关闭</a><h3>'+title+'</h3>'+msg;
		document.body.appendChild(d);
		d.firstChild.onclick=function(e){
			e.preventDefault();d.parentNode.removeChild(d);
		};
		return d;
	}
}
var ff=null,key='__ge_firefox',	// For Greasemonkey or Scriptish
		firefox=/Firefox\//.test(navigator.userAgent);
//if(firefox) {
	ff=unsafeWindow[key];
	if(!ff) ff=unsafeWindow[key]={};
//}
utils=getObj('utils');
if(!utils)
	notice('未检测到依赖脚本!','请确认已安装并启用:<br><a target=_blank href=https://greasyfork.org/scripts/118>Tieba Utilities</a><br><p align=right>——寂寞的原子</p>');
if(firefox) this.injectScript=function(s) {
		var c=document.createElement('script');
		c.innerHTML=s;c.async=true;
		document.body.appendChild(c);
		document.body.removeChild(c);
}
})();