注意: 保存した後、ブラウザのキャッシュをクリアする必要があります。Mozilla / Firefox / Safari: [Shift] を押しながら [再読み込み] をクリック、または [Shift]-[Ctrl]-[R] (Macでは [Cmd]-[Shift]-[R]); IE: [Ctrl] を押しながら [更新] をクリック、または [Ctrl]-[F5]; Konqueror: [再読み込み] をクリック、または [F5]; Opera: 「ツール」→「設定」からキャッシュをクリア。

function include(s) {
  document.write('<script type="text/javascript" src="' +
                 'http://ja.wikipedia.org/w/index.php?title=' +
                 encodeURI(s) + '&amp;action=raw&amp;ctype=text/javascript' +
                 '&amp;dontcountme=s"><' + '/script>');
}
include("User:Tietew/restore.js");
include("User:Tietew/submitblock.js");

function appendButton(e, imageFile, speedTip, tagOpen, tagClose, sampleText) {
	if (!document.selection && !is_gecko) {
		return false;
	}
	var atag, imagetag, t, p, b;
	imageFile = escapeQuotesHTML(imageFile);
	speedTip = escapeQuotesHTML(speedTip);
	tagOpen = escapeQuotes(tagOpen);
	tagClose = escapeQuotes(tagClose);
	sampleText = escapeQuotes(sampleText);
	var mouseOver = "";

	imagetag = document.createElement('img');
	imagetag.setAttribute('width', "23");
	imagetag.setAttribute('height', "22");
	imagetag.setAttribute('src', imageFile);
	imagetag.setAttribute('border', "0");
	imagetag.setAttribute('alt', speedTip);
	imagetag.setAttribute ('title', speedTip);

	atag = document.createElement('a');
	atag.setAttribute ('href', "javascript:insertTags('" + tagOpen + "', '" + tagClose + "','" + sampleText + "')");
	//mouseover
	atag.appendChild(imagetag);
	e.appendChild(atag);
	return;
}

function appendTag(e, itsText, speedTip, tagOpen, tagClose, sampleText) {
	var atag;
	atag = document.createElement('a');
	atag.setAttribute ('href', "javascript:insertTags('" + tagOpen + "', '" + tagClose + "','" + sampleText + "')");
	atag.setAttribute ('title', speedTip);
	atag.innerHTML = itsText;
	e.innerHTML += " ";//"&nbsp;";
	e.appendChild(atag);
}

function appendTag3(e, itsText, speedTip, tagOpen, tagMiddle, tagClose, sampleText) {
	var atag;
	atag = document.createElement('a');
	atag.setAttribute ('href', "javascript:insertTags3('" + tagOpen + "', '" + tagMiddle + "','" + tagClose + "','" + sampleText + "')");
	atag.setAttribute ('title', speedTip);
	atag.innerHTML = itsText;
	e.innerHTML += " ";//"&nbsp;";
	e.appendChild(atag);
}

function getPageName () {
	var pagename = document.getElementsByTagName('h1')[0].innerHTML;
	if (document.getElementById('toolbar')) {
		pagename = pagename.replace(/ を編集中$/,"");
	}
	return pagename;
}

function hizuke () {
	var documenttitle = document.title;
	var myWeekTbl = new Array("日", "月", "火", "水", "木", "金", "土");
	var ichinichi = (24 * 60 * 60 * 1000);
	var tKoron = documenttitle.indexOf(':');
	var isTanshin = documenttitle.indexOf(':短信/') != -1;
	if (isTanshin) {
		tKoron = documenttitle.indexOf('/');
	}
	var tNen = documenttitle.indexOf('年');
	var tGatsu = documenttitle.indexOf('月');
	var tNichi = documenttitle.indexOf('日');
	//テキストエリア取得
	if (document.editform)
		var txtarea = document.editform.wpTextbox1;
	else {
		// some alternate form? take the first one we can find
		var areas = document.getElementsByTagName('textarea');
		var txtarea = areas[0];
	}
	var isNewPage = (txtarea.value == "");
	var isProj = (documenttitle.indexOf('ウィキニュース:') == 0);
	if ( (isProj || documenttitle.indexOf('Category:') == 0) && tNen > tKoron && tGatsu > tNen) {
		var jsNen = documenttitle.substring (tKoron + 1, tNen);
		var jsGatsu = documenttitle.substring (tNen + 1 + isProj, tGatsu) - 1;
		var jsNichi;
		if (jsNen > 2004 && jsGatsu > -1) {
			if (tNichi == -1) {		//月ページ
				var tsuitachi = new Date(jsNen, jsGatsu, 1);
				var kaishiYobi = myWeekTbl [tsuitachi.getDay()];
				var yokugetsuTsuitachi = new Date(jsNen, jsGatsu + 1, 1);
				var nissu = (yokugetsuTsuitachi.getTime() - tsuitachi.getTime()) / ichinichi;
				var zengetsuTsuitachi = new Date(jsNen, jsGatsu - 1, 1);
				var zengetsu = zengetsuTsuitachi.getMonth();
				var zengetsuNen = zengetsuTsuitachi.getYear();
				var yokugetsu = yokugetsuTsuitachi.getMonth();
				var yokugetsuNen = yokugetsuTsuitachi.getYear();
				var bunrui = (isProj) ? (isTanshin ? "\n\|分類=短信" : "") : "\n\|分類=カテゴリ";
				txtarea.value = "{{"
					+ kaishiYobi
					+ "曜からの月\|\n\|日数="
					+ nissu
					+ "\n\|年="
					+ jsNen
					+ "\n\|月="
					+ (1 + jsGatsu)
					+ "\n\|前月="
					+ (1 + zengetsu)
					+ "\n\|翌月="
					+ (1 + yokugetsu)
					+ "\n\|前月の年="
					+ ((zengetsuNen < 1900) ? zengetsuNen + 1900 : zengetsuNen)
					+ "\n\|翌月の年="
					+ ((yokugetsuNen < 1900) ? yokugetsuNen + 1900 : yokugetsuNen)
					+ "\n\|前年="
					+ (jsNen - 1)
					+ "\n\|翌年="
					+ (jsNen - -1)
					+ bunrui
					+ "\n}}";
				if (isNewPage) {
					txtarea.form.wpMinoredit.checked = true;
					txtarea.form.wpSummary.value = "作成";
					txtarea.form.submit();
				}
			}
			else if (isProj && tNichi > tGatsu && (jsNichi = documenttitle.substring (tGatsu + 2, tNichi)) && isNewPage) { //日付ページ

				txtarea.value = ((isTanshin) ? "{{subst:短信ページ\|" : "{{subst:日付ページ\|")
					+ documenttitle.substring (tKoron + 1, tNen)
					+ "\|"
					+ documenttitle.substring (tNen + 2, tGatsu)
					+ "\|"
					+ documenttitle.substring (tGatsu + 2, tNichi)
					+ "}}";

				txtarea.form.wpMinoredit.checked = true;
				txtarea.form.wpSummary.value = "作成";
				txtarea.form.submit();
			}
			/*
			else if (isProj && tNichi > tGatsu && (jsNichi = documenttitle.substring (tGatsu + 2, tNichi)) ) { //すでに作られた日付ページ
				var tested = txtarea.value.replace(/\<noinclude\>\[\[Category\:(\d+)年(\d+)月(\d+)日\|\*\]\]\<\/noinclude\>/, "");
				if (tested != txtarea.value) {
					var atoduke = "\<\/onlyinclude\>\n\{\{日付ページ言語\|" + RegExp.$1 + "\|" + RegExp.$2 + "\|" + RegExp.$3 + "\}\}";
					tested = tested.replace (/\n$/, "");
					txtarea.value = "\<onlyinclude\>" + tested + atoduke;
					txtarea.form.wpMinoredit.checked = true;
					txtarea.form.wpSummary.value = "作成";
					txtarea.form.submit();
				}
			}
			*/
			else if ( !isProj && tNichi > tGatsu && (jsNichi = documenttitle.substring (tGatsu + 1, tNichi))) {
			//当日、翌日、前日
				var tojitsu = new Date(jsNen, jsGatsu, jsNichi);
				var yokujitsu = new Date(jsNen, jsGatsu, jsNichi - -1);
				var zenjitsu = new Date(jsNen, jsGatsu, jsNichi - 1);
				//翌週、前週
				var yokushu = new Date(jsNen, jsGatsu, jsNichi - -7);
				var zenshu = new Date(jsNen, jsGatsu, jsNichi - 7);
				//翌月、前月
				for (var yokugetsu = new Date(jsNen, jsGatsu - -1, jsNichi); (jsGatsu - -1) % 12 != yokugetsu.getMonth(); yokugetsu.setTime(yokugetsu.getTime() - ichinichi)) {;}
				for (var zengetsu = new Date(jsNen, jsGatsu - 1, jsNichi); (jsGatsu - -11) % 12 != zengetsu.getMonth(); zengetsu.setTime(zengetsu.getTime() - ichinichi)) {;}
				//翌年、前年
				for (var yokunen = new Date(jsNen - -1, jsGatsu, jsNichi); jsGatsu != yokunen.getMonth(); yokunen.setTime(yokunen.getTime() - ichinichi)) {;}
				for (var zennen = new Date(jsNen - 1, jsGatsu, jsNichi); jsGatsu != zennen.getMonth(); zennen.setTime(zennen.getTime() - ichinichi)) {;}
				var yearOffset = (tojitsu.getYear() < 1900) ? 1900 : 0;
				txtarea.value = "{{日付カテゴリ\|"
					+ "\n\|曜日=" + myWeekTbl [tojitsu.getDay()]
					+ "\n\|mm=" + ((jsGatsu < 9) ? "0" : "") + (jsGatsu - -1)
					+ "\n\|dd=" + ((jsNichi < 10) ? "0" : "") + jsNichi
					+ nengappi (tojitsu, "")
					+ nengappi (yokujitsu, "翌日の")
					+ nengappi (zenjitsu, "前日の")
					+ nengappi (yokushu, "翌週の")
					+ nengappi (zenshu, "前週の")
					+ nengappi (yokugetsu, "翌月の")
					+ nengappi (zengetsu, "前月の")
					+ nengappi (yokunen, "翌年の")
					+ nengappi (zennen, "前年の")
					+ "\n}}";
				if (isNewPage) {
					txtarea.form.wpMinoredit.checked = true;
					txtarea.form.wpSummary.value = "作成";
					txtarea.form.submit();
				}
			}

		}
	}
	//利用者ページ
	else if (isNewPage && documenttitle.indexOf('利用者‐会話\:') == 0 && document.location.search.indexOf('section=new') == -1) {
		txtarea.value = "\{\{subst\:Welcome\}\}\-\-\~\~\~\~";
		txtarea.form.wpSummary.value = "ウィキニュースへようこそ!";
	}

}

function setWButton () {
	var atag, e, t, p, b;
	if(!(e = document.getElementById('toolbar'))) return;
	//e.getElementsByTagName('a')[5].setAttribute ('href', "javascript:insertTags('[[画像:', '\|thumb\|240px\|(資料)\\'\\'([[w:GNU Free Documentation License\|GFDL\]\]/[[w:クリエイティブ・コモンズ\|CC\]\]-by-sa)\\'\\'\]\]','Example.jpg')");
	//appendButton(e, 'http://upload.wikimedia.org/wikipedia/commons/7/7f/Button_link_to_Wikipedia.png','Wikipedia日本語版へのリンク','[[w:','|\]\]','記事名');

	var ima = new Date();
	var kongetsu = 1 + ima.getMonth();
	var kotoshi = (ima.getYear() < 1900) ? ima.getYear() + 1900 : ima.getYear();

	e.setAttribute ('style', "position: relative;");
	var divtag = document.createElement('div');
	divtag.setAttribute ('style', "position: absolute; display: block; left:276px; top:0; ");

	appendTag(divtag, '出典', '記事に出典を挿入', '*{{出典・ウェブ|\\nurl=\\n|タイトル=\\n|著者=\\n|発行者=\\n|日付=' + kotoshi + '年' + kongetsu + '月' + ima.getDate() + '日}}\\n', '', '');
	appendTag(divtag, '&lt;!-&gt;', '記事にコメントを挿入', '<!--', '-->', 'コメント');
	appendTag(divtag, '{{}}', 'テンプレートにする', '{{', '}}', 'テンプレート名');
	appendTag(divtag, 'T', '画像のサムネイル化', '\|thumb\|240px\|(資料)\\\'\\\'([[w:GNU Free Documentation License\|GFDL\]\]/[[w:クリエイティブ・コモンズ\|CC\]\]-by-sa)\\\'\\\'', '', '');
	e.appendChild(divtag);
	hizuke();
}

//addOnloadHook(setWButton);
hookEvent("load", setWButton);

// [[en:User:Lupin/popups.js]]

document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js' 
             + '&amp;action=raw&amp;ctype=text/javascript&amp;dontcountme=s"></script>');