Greasy Fork

Greasy Fork is available in English.

I'm wenku8 admin!

通过简单的几行代码把用户伪装成wenku8管管

当前为 2021-06-30 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/428403/945856/I%27m%20wenku8%20admin%21.js

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

main();

function main() {
	if (injectOpener()) {
		window.close();
		return false;
	};

	getDocument('https://www.wenku8.net/userinfo.php?id=2', function(oDoc) {
		const content = document.querySelector('#content');
		const table = content.querySelector('table');
		const oContent = oDoc.querySelector('#content');
		const otable = oContent.querySelector('table');

		content.innerHTML = oContent.innerHTML;
	});
}

function injectOpener() {
	if (location.href !== 'about:blank' || !window.opener) {return false;};

	const scripts = document.scripts;
	const oWin = window.opener.window;
	const oDoc = window.opener.document;
	for (const script of scripts) {
		if (!script.src.match(/^https?:\/\//)) {continue;};
		loadJS(script.src, null, oDoc);
	}
	return true;
}

// Load javascript from given url
function loadJS(url, callback, oDoc=document) {
	var script = document.createElement('script'),
		fn = callback || function () {};
	script.type = 'text/javascript';

	//IE
	if (script.readyState) {
		script.onreadystatechange = function () {
			if (script.readyState == 'loaded' || script.readyState == 'complete') {
				script.onreadystatechange = null;
				fn();
			}
		};
	} else {
		//其他浏览器
		script.onload = function () {
			fn();
		};
	}

	script.src = url;
	oDoc.getElementsByTagName('head')[0].appendChild(script);
}

// Download and parse a url page into a html document(dom).
// when xhr onload: callback.apply([dom, args])
function getDocument(url, callback, args = []) {
	const xhr = new XMLHttpRequest();
	xhr.open('GET', url);
	xhr.responseType = 'blob';
	xhr.onload = function (response) {
		const htmlblob = xhr.response;
		const reader = new FileReader();
		reader.onload = function (e) {
			const htmlText = reader.result;
			const dom = new DOMParser().parseFromString(htmlText, 'text/html');
			args = [dom].concat(args);
			callback.apply(null, args);
			//callback(dom, htmlText);
		}
		reader.readAsText(htmlblob, 'GBK');
	}
	xhr.send();
}