MUJS 2.0

A Library for UserScripts.

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/10546/57895/MUJS%2020.js

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

var sel = function(id){
var sel = document.querySelector(id);
return sel;
}

var selAll = function(id){
var selAll = document.querySelectorAll(id);
return selAll;
}

var del = function(elem){
sel(elem).parentNode.removeChild(sel(elem));
}

var write = function(left,top,text){
var a = document.getElementsByTagName('body')[0];
var b = document.createElement('div');
b.innerHTML = text;
b.style.position = 'absolute';
b.style.left = left+'px';
b.style.top = top+'px';
a.appendChild(b);
}

var bgColor = function(color){
document.body.style.background = color;
}

var display = function(element,attr){
var x = document.querySelector(element);
if(attr==0||attr=='none'||attr=='hide'||attr=='false'){x.style.display = 'none';}
if(attr==1||attr=='block'||attr=='show'||attr=='true'){x.style.display = 'block';}
}

var move = function(id,pos,left,top){
sel(id).style.position=pos;
sel(id).style.left=left+'px';
sel(id).style.top=top+'px';
}

var injectCss = function(css){
var head = document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = "text/css";
style.innerHTML = css;
head.insertBefore(style,head.childNodes[1]);
}

var bakeCookie = function(name,content,toDate){
var hdate = new Date();
hdate.setDate(hdate.getDate() + toDate).toLocaleString();
str=name+'='+content;
document.cookie= str+';expires='+hdate;
//syntax for naming cookies
//bakeCookie("cookiename","content",10000);
}

var analyzeCookie = function(name){
c = document.cookie.toString();
var cookie_array = document.cookie.toString().split(';');
pos = c.search(name);
r = cookie_array[pos];
f=r.toString().split('=')[1];
return f;
//analyzeCookie("cookieName") //returns the content of the cookie
}

var eatCookie = function(name){
c = document.cookie.toString();
var cookie_array = document.cookie.toString().split(';');
pos = c.search(name);
r = cookie_array[pos];
var hexp_date = new Date();
hexp_date.setDate(hexp_date.getDate() - 10000).toLocaleString();
document.cookie = r+';expires='+hexp_date;
//eatCookie("cookieName") //without content or date
}

var pushTo = function(elem,id,host,loc){
var host = document.querySelector(host);
var x = document.createElement(elem);
x.id = id;
if(loc==1||loc==null||loc=='after'){host.appendChild(x);}
if(loc==0||loc=='before'){host.parentNode.insertBefore(x,host);}
}

var typeTo = function(element,html){
var x = document.querySelector(element);
x.innerHTML = html;
}


var getData = function(site,target,type){
if(target=='crossDomain'){
var link='http://query.yahooapis.com/v1/public/yql?q=select * from html where url="'+site+'"&format='+type+'';}
else if(target=='localDomain'||target==null){var link=site;}
else{alert("Target parameter has to be either localDomain or crossDomain");}
xml = new XMLHttpRequest();
xml.open('get',link,false);xml.send();
queryData = xml.responseText;
return queryData;
}

var showQueryData = function(qData){
pushTo('textarea','queryDataContainer','body')
typeTo('#queryDataContainer',qData);
sel('#queryDataContainer').rows=15;
sel('#queryDataContainer').cols=150;
}

var mouse = function(event,id){
	x=document.querySelector(id);
	y=x.href; 	//getting link
	o=x.onclick; //check whether there is an onclick function
	t=x.target; 	//check target

	if(t==""){t="_self"}	//assign target if none

if(o==null && y!=null){	//This is for links without onclick functions with href
	x.onclick=function(){
		window.open(y,t);
	}
		//This is the if statement to fire the event
		if(event=='click' && id!=null){	//Firing the click event
			x.onclick();
		}
}else if(o!=null && y!=null){ //This is for links with onclick functions & href
		if(event=='click' && id!=null){	//Firing the click event
			x.onclick();
		}
	window.open(y,t);
}else if(o!=null && y==null){ //This is for links with onclick function without href
	x.onclick();
}

if(event=='mouseover'){
	x.onmouseover();
}
//mouse('click','#id');
//mouse('mouseover','#id');
}