Greasy Fork

Greasy Fork is available in English.

Forum(Discuz! X) Base-Profile One-Clicked Filler

Discuz! X-论坛-基本资料-一键填写

当前为 2017-01-22 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Forum(Discuz! X) Base-Profile One-Clicked Filler
// @description  Discuz! X-论坛-基本资料-一键填写
// @version      1.0.17012102
// @author       DanoR
// @namespace    http://weibo.com/zheung
// @grant        none
// @include      *://*op=base*
// ==/UserScript==

(function() {
	var info = {
		birthdate: {
			data: [1993, 8, 10],
			privacy: 3
		},
		realname: {
			data: '',
			privacy: 3
		},
		gender: {
			data: 1,
			privacy: 3
		},
		bloodtype: {
			data: 'O',
			privacy: 3
		},
		lookingfor: {
			data: '婚姻',
			privacy: 3
		},
		affective: {
			data: '单身',
			privacy: 3
		},
		birthplace: {
			data: ['广东省', '广州市'],
			privacy: 3
		},
		resideplace: {
			data: ['广东省', '广州市'],
			privacy: 3
		}
	};

	document.querySelector('button#profilesubmitbtn.pn.pnc').parentNode.innerHTML +=
	'<button id="fill" type="button" class="pnc pn"><strong>填写</strong></button>';
	document.querySelector('button#fill.pn.pnc').onclick = fill;

	function fill() {
		var i;

		var privacys = document.querySelectorAll('td.p>select');
		for(i=0; i<privacys.length; i++) privacys[i].value = 3;

		document.querySelector('input#realname.px').value = info.realname.data;
		document.querySelector('input#affectivestatus.px').value = info.affective.data;
		document.querySelector('input#lookingfor.px').value = info.lookingfor.data;

		document.querySelector('select#gender.ps').value = info.gender.data;
		document.querySelector('select#bloodtype.ps').value = info.bloodtype.data;

		var year = document.querySelector('select#birthyear.ps');
		year.value = info.birthdate.data[0]; year.onchange();
		var month = document.querySelector('select#birthmonth.ps');
		month.value = info.birthdate.data[1]; month.onchange();
		document.querySelector('select#birthday.ps').value = info.birthdate.data[2];

		var provinceBirth = document.querySelector('select#birthprovince.ps');
		provinceBirth.value = info.birthplace.data[0];
		provinceBirth.onchange();

		var provinceReside = document.querySelector('select#resideprovince.ps');
		provinceReside.value = info.resideplace.data[0];
		provinceReside.onchange();

		var intervalID = setInterval(function() {
			var cityBirth = document.querySelector('select#birthcity.ps');
			if(cityBirth) cityBirth.value = info.birthplace.data[1];
			var cityReside = document.querySelector('select#residecity.ps');
			if(cityReside) cityReside.value = info.resideplace.data[1];

			if(cityBirth.value == info.birthplace.data[1] && cityReside.value == info.resideplace.data[1]) clearInterval(intervalID);
		}, 2014);
	}
})();