コンテンツにスキップ

利用者:Kocgs/common.js

お知らせ: 保存した後、ブラウザのキャッシュをクリアしてページを再読み込みする必要があります。

多くの WindowsLinux のブラウザ

  • Ctrl を押しながら F5 を押す。

Mac における Safari

  • Shift を押しながら、更新ボタン をクリックする。

Mac における ChromeFirefox

  • Cmd Shift を押しながら R を押す。

詳細についてはWikipedia:キャッシュを消すをご覧ください。

//<source lang="javascript">

window.DisamAssist = jQuery.extend( true, {
	cfg: {
		/*
		 * Categories where disambiguation pages are added (usually by a template like {{Disambiguation}}
		 */
		disamCategories: ['All disambiguation pages'],
		
		/*
		 * "Canonical names" of the templates that may appear after ambiguous links
		 * and which should be removed when fixing those links
		 */
		disamLinkTemplates: [
			'Disambiguation needed',
			'Ambiguous link',
			'Amblink',
			'Dab needed',
			'Disamb-link',
			'Disambig needed',
			'Disambiguate',
			'Dn',
			'Needdab'
		],
		
		/*
		 * "Canonical names" of the templates that designate intentional links to
		 * disambiguation pages
		 */
		disamLinkIgnoreTemplates: [
			'R from ambiguous page',
			'R to disambiguation page',
			'R from incomplete disambiguation'
		],
		
		/*
		 * Format string for "Foo (disambiguation)"-style pages
		 */
		 disamFormat: '$1 (disambiguation)',
		
		/*
		 * Regular expression matching the titles of disambiguation pages (when they are different from
		 * the titles of the primary topics)
		 */
		disamRegExp: '^(.*) \\(disambiguation\\)$',
		
		/*
		 * Text that will be inserted after the link if the user requests help. If the value is null,
		 * the option to request help won't be offered
		 */
		disamNeededText: '{{dn|date={{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}}}',
		
		/*
		 * Content of the "Foo (disambiguation)" pages that will be created automatically when using
		 * DisamAssist from a "Foo" page
		 */
		redirectToDisam: '#REDIRECT [[$1]] {{R to disambiguation page}}',
		
		/*
		 * Whether intentional links to disambiguation pages can be explicitly marked by adding " (disambiguation)"
		 */
		intentionalLinkOption: true,
		
		/*
		 * Namespaces that will be searched for incoming links to the disambiguation page (pages in other
		 * namespaces will be ignored)
		 */
		targetNamespaces: [0, 6, 10, 14, 100, 108],
		
		/*
		 * Number of backlinks that will be downloaded at once
		 * When using blredirect, the maximum limit is supposedly halved
		 * (see http://www.mediawiki.org/wiki/API:Backlinks)
		 */
		backlinkLimit: 250,
		
		/*
		 * Number of titles we can query for at once
		 */
		queryTitleLimit: 50,
	
		/*
		 * Number of characters before and after the incoming link that will be displayed
		 */
		radius: 300,
	
		/*
		 * Height of the context box, in lines
		 */
		numContextLines: 4,
	
		/*
		 * Number of pages that will be stored before saving, so that changes to them can be
		 * undone if need be
		 */
		historySize: 2,
		
		/*
		 * Minimum time in seconds since the last change was saved before a new edit can be made. A
		 * negative value or 0 disables the cooldown. Users with the "bot" right won't be affected by
		 * the cooldown
		 */
		editCooldown: 5,
		
		/*
		 * Specify how the watchlist is affected by DisamAssist edits. Possible values: "watch", "unwatch",
		 * "preferences", "nochange"
		 */
		watch: 'nochange'
	},

	txt: {
		start: 'Disambiguate links',
		startMain: 'Disambiguate links to primary topic',
		startSame: 'Disambiguate links to DAB',
		close: 'Close',
		undo: 'Undo',
		omit: 'Skip',
		refresh: 'Refresh',
		titleAsText: 'Different target',
		disamNeeded: 'Tag {{dn}}',
		intentionalLink: 'Intentional link to DAB',
		titleAsTextPrompt: 'Specify the new target:',
		removeLink: 'Unlink',
		optionMarker: ' [Link here]',
		targetOptionMarker: ' [Current target]',
		redirectOptionMarker: ' [Current target (redirected)]',
		pageTitleLine: 'In <a href="$1">$2</a>:',
		noMoreLinks: 'No more links to disambiguate.',
		pendingEditCounter: 'Saving: $1; in history: $2',
		pendingEditBox: 'DisamAssist is currently saving changes ($1).',
		pendingEditBoxTimeEstimation: '$1; approximate time remaining: $2',
		pendingEditBoxLimited: 'Please don\'t close this tab until all pending changes have been saved. You may keep '
			+ 'editing Wikipedia in a different tab, but be advised that using multiple instances of DisamAssist at '
			+ 'the same time is discouraged, as a high number of edits over a short time period may be disruptive.',
		error: 'Error: $1',
		fetchRedirectsError: 'Unable to fetch redirects: "$1".',
		getBacklinksError: 'Unable to download backlinks: "$1".',
		fetchRightsError: 'Unable to fetch user rights: "$1",',
		loadPageError: 'Unable to load $1: "$2".',
		savePageError: 'Unable to save changes to $1: "$2".',
		dismissError: 'Dismiss',
		pending: 'There are unsaved changes in DisamAssist. To save them, please press Close',
		editInProgress: 'DisamAssist is currently performing changes. If you close the tab now, they may be lost.',
		ellipsis: '...',
		notifyCharacter: '✔',
		summary: 'Disambiguating links to [[$1]] ($2) using [[User:Qwertyytrewqqwerty/DisamAssist|DisamAssist]].',
		summaryChanged: 'link changed to [[$1]]',
		summaryOmitted: 'link skipped',
		summaryRemoved: 'link removed',
		summaryIntentional: 'intentional link to DAB',
		summaryHelpNeeded: 'help needed',
		summarySeparator: '; ',
		redirectSummary: 'Creating redirect to [[$1]] using [[User:Qwertyytrewqqwerty/DisamAssist|DisamAssist]].'
	}
}, window.DisamAssist || {} );

mw.loader.load( '//es.wikipedia.org/w/index.php?title=Usuario:Qwertyytrewqqwerty/DisamAssist-core.js&action=raw&ctype=text/javascript' );
mw.loader.load( '//es.wikipedia.org/w/index.php?title=Usuario:Qwertyytrewqqwerty/DisamAssist.css&action=raw&ctype=text/css', 'text/css' );

//</source>

// 即時削除入力補助スクリプト
// 最終更新:2019-12-22
// 
// 即時削除タグの基準番号を確認するのが煩わしいので、プルダウンメニューを使ってタグを貼り付けできるようにしたもの
// ツールボックスのリンクをクリックしたときのみ、ページ上部にプルダウンメニューが表示される
// 即時削除マシーン遊びをやられると困るので、既に即時削除タグが貼られている場合には反応しない

$(function() {
	// 未作成のページに反応させない
	if(mw.config.get("wgArticleId") != "0") {
		// 編集画面以外であれば反応する
		if(mw.config.get("wgAction") != "edit" && mw.config.get('wgRestrictionEdit')[0] != "sysop") {
			
			// 編集タブのURLを取得する
			if(mw.config.get("skin") !== "minerva") {
				$editlink = $("#ca-edit>a").attr("href");
			}
			
			// ツールボックスに即時削除リンクを追加する
			if(mw.config.get("skin") !== "minerva") {
				mw.util.addPortletLink("p-tb", $editlink + "&csdhelper=true", "このページを即時削除依頼" , "t-csd", "編集画面を開き、即時削除タグを貼り付ける");
			}
		}
	}
	
	// ツールボックスから編集画面を開いたときの処理、パラメータが渡された場合のみ処理を実行する
	if(mw.config.get("wgAction") == "edit" && $(location).attr("search").indexOf("csdhelper=true") > -1 && mw.config.get("skin") !== "minerva") {
	
		// 編集画面上部にプルダウンメニューを追加する
		$("#editform")
			.prepend(
				$("\x3Cselect/\x3E")
					.attr({"name": "csdList"})
						.append(
							$("\x3Coption/\x3E")
								.attr({"value": ""})
								.append("選択してください"),
							$("\x3Coption/\x3E")
								.attr({"value": "全般1"})
								.append("全般1 意味不明な内容のページ"),
							$("\x3Coption/\x3E")
								.attr({"value": "全般2"})
								.append("全般2 テスト投稿"),
							$("\x3Coption/\x3E")
								.attr({"value": "全般3"})
								.append("全般3 荒らしもしくはいたずら"),
							$("\x3Coption/\x3E")
								.attr({"value": "全般4"})
								.append("全般4 露骨な宣伝・広告のみが目的"),
							$("\x3Coption/\x3E")
								.attr({"value": "全般5"})
								.append("全般5 削除されたページの改善なき再作成"),
							$("\x3Coption/\x3E")
								.attr({"value": "全般6"})
								.append("全般6 ウィキペディア内のコピペによる作成"),
							$("\x3Coption/\x3E")
								.attr({"value": "全般8"})
								.append("全般8 初版投稿者による依頼または白紙化"),
							$("\x3Coption/\x3E")
								.attr({"value": "全般9"})
								.append("全般9 明白な著作権侵害"),
							$("\x3Coption/\x3E")
								.attr({"value": "記事1"})
								.append("記事1 定義なし"),
							$("\x3Coption/\x3E")
								.attr({"value": "記事2"})
								.append("記事2 言語間リンク・カテゴリ・外部リンクのみ"),
							$("\x3Coption/\x3E")
								.attr({"value": "リダイレクト1-1"})
								.append("リダイレクト1-1 直接関係のないページへのリダイレクト"),
							$("\x3Coption/\x3E")
								.attr({"value": "リダイレクト1-2"})
								.append("リダイレクト1-2 単純な書き誤り"),
							$("\x3Coption/\x3E")
								.attr({"value": "リダイレクト1-3"})
								.append("リダイレクト1-3 転送先がないリダイレクト"),
							$("\x3Coption/\x3E")
								.attr({"value": "リダイレクト1-4"})
								.append("リダイレクト1-4 他言語版へのリダイレクト"),
							$("\x3Coption/\x3E")
								.attr({"value": "リダイレクト2-1"})
								.append("リダイレクト2-1 半角と全角の使い分け違反"),
							$("\x3Coption/\x3E")
								.attr({"value": "リダイレクト2-2"})
								.append("リダイレクト2-2 作品名を鍵括弧等でくくったもの"),
							$("\x3Coption/\x3E")
								.attr({"value": "リダイレクト2-3"})
								.append("リダイレクト2-3 作品名以外の記事名における読み・別表記等の併記"),
							$("\x3Coption/\x3E")
								.attr({"value": "リダイレクト2-5"})
								.append("リダイレクト2-5 曖昧さ回避括弧の使い方違反"),
							$("\x3Coption/\x3E")
								.attr({"value": "リダイレクト2-6"})
								.append("リダイレクト2-6 漢字表記人名の姓名間の空白"),
							$("\x3Coption/\x3E")
								.attr({"value": "リダイレクト3-1"})
								.append("リダイレクト3-1 改名提案を経た曖昧さ回避括弧付きの移動の残骸"),
							$("\x3Coption/\x3E")
								.attr({"value": "リダイレクト3-2"})
								.append("リダイレクト3-2 移動依頼を経た曖昧さ回避括弧付きの移動の残骸"),
							$("\x3Coption/\x3E")
								.attr({"value": "リダイレクト4"})
								.append("リダイレクト4 唯一の投稿者による移動の残骸で本人依頼のもの"),
							$("\x3Coption/\x3E")
								.attr({"value": "ファイル1-2"})
								.append("ファイル1-2 コモンズと重複(コピー)"),
							$("\x3Coption/\x3E")
								.attr({"value": "ファイル1-3"})
								.append("ファイル1-3 コモンズと重複(他プロジェクト由来)"),
							$("\x3Coption/\x3E")
								.attr({"value": "ファイル1-4"})
								.append("ファイル1-4 コモンズと重複(同一投稿者)"),
							$("\x3Coption/\x3E")
								.attr({"value": "ファイル1-5"})
								.append("ファイル1-5 コモンズへ移動"),
							$("\x3Coption/\x3E")
								.attr({"value": "ファイル3"})
								.append("ファイル3 重複ファイル"),
							$("\x3Coption/\x3E")
								.attr({"value": "ファイル5"})
								.append("ファイル5 出典またはライセンス不明のまま1週間経過"),
							$("\x3Coption/\x3E")
								.attr({"value": "ファイル6"})
								.append("ファイル6 自由利用できないファイル"),
							$("\x3Coption/\x3E")
								.attr({"value": "ファイル7"})
								.append("ファイル7 コモンズのファイルページ"),
							$("\x3Coption/\x3E")
								.attr({"value": "ファイル8"})
								.append("ファイル8 存在しないファイルのファイルページ"),
							$("\x3Coption/\x3E")
								.attr({"value": "ファイル9"})
								.append("ファイル9 初版投稿後7日以内の投稿者による依頼"),
							$("\x3Coption/\x3E")
								.attr({"value": "カテゴリ1"})
								.append("カテゴリ1 初版からリダイレクト"),
							$("\x3Coption/\x3E")
								.attr({"value": "カテゴリ3"})
								.append("カテゴリ3 私的カテゴリ"),
							$("\x3Coption/\x3E")
								.attr({"value": "カテゴリ6"})
								.append("カテゴリ6 改名提案を経て未使用となったカテゴリ"),
							$("\x3Coption/\x3E")
								.attr({"value": "利用者ページ1"})
								.append("利用者ページ1 本人希望"),
							$("\x3Coption/\x3E")
								.attr({"value": "利用者ページ2"})
								.append("利用者ページ2 登録されていない利用者の利用者ページ"),
							$("\x3Coption/\x3E")
								.attr({"value": "利用者ページ3"})
								.append("利用者ページ3 IPユーザーの利用者ページ")
						),
				
				// 念のため、方針へのリンクも用意しておく
				$("\x3Csmall/\x3E")
					.append("(" ,
					
						$("\x3Ca/\x3E")
							.attr({"href": "/wiki/Wikipedia:%E5%8D%B3%E6%99%82%E5%89%8A%E9%99%A4%E3%81%AE%E6%96%B9%E9%87%9D", "target": "_blank", "title": "別画面で方針ページを開きます"})
							.append("即時削除の方針")
					
					, ")"),
				
				// 2のパラメータ入力欄を無効化した状態で配置しておく
				$("\x3Cbr/\x3E"),
				$("\x3Cinput/\x3E")
					.attr({"type": "text" , "name": "txtReason", "size": "65", "disabled": "disabled"}),
				$("\x3Cinput/\x3E")
					.attr({"type": "button", "name": "btnReason", "value": "入力完了!", "disabled": "disabled", "onclick": "$csdTagDone()"}),
				$("\x3Cbr/\x3E")
			);
	}
});


$(function() {
	//セレクトボックスが切り替わったら処理を実行する
	$("select[name=csdList]").change(function() {
		// テキストエリアの内容を取得する
		var $wikiTxt = $("textarea#wpTextbox1").val();
		
		// 即時削除タグの有無を確認する
		if($wikiTxt.indexOf("{{即時削除") > -1 || $wikiTxt.indexOf("{{sd") > -1) {
			// 既にタグが貼られている場合、二段目のテキストボックスを無効化
			$("input[name=btnReason]").prop("disabled", true);
			$("input[name=txtReason]").prop("disabled", true);
			$("input[name=txtReason]").val("");
			
			// タグが貼られている場合は処理を抜ける
			return false;
		}
		
		
		// 即時削除タグがなければ続行する
		
		// 2のパラメータが必要な番号と、入力欄に出す説明
		var $delReason = { 
			"全般4":"説明を記入してください",
			"全般5":"削除依頼のサブページ名",
			"全般6":"コピペ元ページ名",
			"全般9":"コピー元URL",
			"記事1":"説明を記入してください",
			"リダイレクト1-2":"書き誤りの箇所を説明してください",
			"リダイレクト2-1":"使い分けが間違っている文字を説明してください",
			"リダイレクト2-5":"使い方の違反内容を説明してください",
			"リダイレクト3-1":"改名提案へのリンクを記入してください",
			"リダイレクト3-2":"移動依頼の該当節へのリンクを示してください",
			"ファイル1-2":"コモンズのファイル名",
			"ファイル1-3":"コモンズのファイル名",
			"ファイル1-4":"コモンズのファイル名",
			"ファイル1-5":"コモンズのファイル名",
			"ファイル3":"コモンズのファイル名",
			"ファイル5":"投稿者への通知先",
			"ファイル6":"自由利用ができない根拠",
			"カテゴリ6":"改名提案へのリンク"
		};
		
		// 選択肢が一番上だった場合、何もしない
		if($("select[name=csdList]").val() === "") {
			// 空白
		}
		// 2のパラメータが必要な場合の処理
		else if(Object.keys($delReason).includes($(this).val())) {
			// 二段目のテキストボックスとボタンを有効化する
			$("input[name=btnReason]").prop("disabled", false);
			$("input[name=txtReason]").prop("disabled", false);
			
			// 配列からパラメータの説明を読み出して出力、全選択状態にする
			$("input[name=txtReason]").val($delReason[$(this).val()]);
			$("input[name=txtReason]").focus();
			$("input[name=txtReason]").select();
		}
		// 2のパラメータが不要であれば、選択したvalue値を即時削除タグに含めた状態で出力
		else {
			$("textarea#wpTextbox1").val("\x7B\x7B即時削除|" + $(this).val() + "\x7D\x7D\r\n" + $("textarea#wpTextbox1").val());
			
			// 年のためテキストボックスとボタンの無効化処理を行っておく
			$("input[name=btnReason]").prop("disabled", true);
			$("input[name=txtReason]").prop("disabled", true);
			$("input[name=txtReason]").val("");
		}
	});
});


// 二段目のテキストボックスを使う場合、入力完了ボタンを押したときに出力
function $csdTagDone() {
	
	// 全般6のみ3のパラメータ追加
	if($("select[name=csdList]").val() == "全般6") {
		$("textarea#wpTextbox1").val("\x7B\x7B即時削除|" + $("select[name=csdList]").val() + "|2=" + $("input[name=txtReason]").val() + "|3=\x3C!-- 言語コード --\x3E\x7D\x7D\r\n" + $("textarea#wpTextbox1").val());
	}
	// 全般6以外は一段目と二段目のvalue値を取得するだけ
	else {
		$("textarea#wpTextbox1").val("\x7B\x7B即時削除|" + $("select[name=csdList]").val() + "|2=" + $("input[name=txtReason]").val() + "\x7D\x7D\r\n" + $("textarea#wpTextbox1").val());
	}
	
	// 二段目のテキストボックスとボタンを空欄にして無効化する
	$("input[name=btnReason]").prop("disabled", true);
	$("input[name=txtReason]").prop("disabled", true);
	$("input[name=txtReason]").val("");
}

/*
 * ページ内リンク切れを表示するカスタムJS
 * Custom JS to show internal dead links in a page
 * 
 * 説明:
 *   カスタムJSとして導入して下さい。
 * 
 * Description:
 *   Use this file as custom JS.
 * 
 * Global variables:
 *   以下のグローバル変数を、このスクリプトを読み込むより前に設定することで、
 *   このスクリプトの動作を制御できます。
 *   (default)
 *   mw.libs.showInternalDeadLink = {
 *     addCSS: true,
 *     showLinks: true,
 *     deferred: $.Deferred(),
 *   };
 *   mw.libs.showInternalDeadLink.addCSS:
 *     trueの時、デフォルトのスタイルを追加します。
 *     falseの時、スタイルを追加しません。自分でCSSを追加してスタイルを設定してください。
 *   mw.libs.showInternalDeadLink.showLinks:
 *     trueの時、リンク切れ部分へのリンクをページ右上に表示します。
 *     falseの時、リンク切れ部分へのリンクを表示しません。
 *   mw.libs.showInternalDeadLink.deferred:
 *     処理完了時に成功するdeferredオブジェクトを設定します。
 * 
 * CSS:
 *   .dead-internal-link
 *     リンク切れのリンク
 *   div.dead-internal-link-links
 *     リンク切れ部分へのリンクを表示する領域
 * 
 * このファイルはパブリックドメインとします。
 * This file is public domain.
 */

(function () {
  'use strict';
  function addDeadInternalLink() {
    $('[href]').each(function (index, elem) {
      var href = elem.getAttribute('href');
      if (href.substr(0, 1) === '#') {
        var anchor = href.substr(1);
        if (anchor !== '' && !document.getElementById(anchor)) {
          $(elem).addClass('dead-internal-link');
        }
      }
    });
  }

  function addCSS() {
    mw.util.addCSS(
      '.dead-internal-link:after{ content: " [内部リンク切れ]"; color: red; font-size: x-small; }\n' +
      ''
    );
  }

  function showLinks() {
    var deadInternalLinks = $('.dead-internal-link');
    function deadLinkId(index) {
      return 'dead_internal_link_' + index;
    }
    if(deadInternalLinks.length > 0){
      var linksDiv = $('<div>').addClass('dead-internal-link-links').prependTo($('.mw-indicators').eq(0));
      var $resultSpan = $('<span>').text('内部リンク切れ: ' + deadInternalLinks.length + ':').appendTo(linksDiv);
      deadInternalLinks.each(function (index, elem) {
        var $elem = $(elem);
        var id = $elem.attr('id');
        if (!id) {
          id = deadLinkId(index + 1);
          $elem.attr('id', id);
        }
        $resultSpan.append(' ');
        $('<a>').attr('href', '#' + id).text(index + 1).appendTo($resultSpan);
      });
      if (mw.libs.showInternalDeadLink.addCSS) {
        mw.util.addCSS(
          'div.dead-internal-link-links{ border: black 1px solid; vertical-align: top; display: inline-block; color: red; font-size: x-small; font-weight: bold; }\n' +
          ''
        );
      }
    }
  }
  function main() {
    addDeadInternalLink();
    if (mw.libs.showInternalDeadLink.addCSS) {
      addCSS();
    }
    if (mw.libs.showInternalDeadLink.showLinks) {
      showLinks();
    }
  }
  $(function () {
    if (!('showInternalDeadLink' in mw.libs)) {
      mw.libs.showInternalDeadLink = {
        addCSS: true,
        showLinks: true,
      };
    }

    mw.libs.showInternalDeadLink.deferred = mw.libs.showInternalDeadLink.deferred || $.Deferred();

    mw.loader.using('mediawiki.util').then(function () {
      main();
      mw.libs.showInternalDeadLink.deferred.resolve();
    });
  });
}) ();