Help:壊れたスクリプトを特定する

This page is a translated version of the page Help:Locating broken scripts and the translation is 38% complete.

ローカル ガジェットまたはユーザー スクリプトに問題がある場合、これらの問題は、壊れた JavaScript コード (ガジェットが記述されているプログラミング言語) または他のコードへの宣言されていない依存関係によって引き起こされることがよくあります。

修正が必要な問題のあるコードや場所を追跡するには、Web ブラウザーの開発者ツールを使用する必要があります。 このツールを特別な URL と組み合わせると、壊れたスクリプトを特定するのに役立ちます。

使用法

最新の構成にしておくこと

まず、ブラウザーが最新であることを確認してください。MediaWiki の機能や一部のスクリプトは、安全上の理由から古いブラウザーではサポートされていません。

そして、ページのキャッシュを破棄することで、強制的にページをソースから再表示させたり、スクリプトを再起動させたりすることができます。

この 2 点で、ほとんどの問題は解決します。

ウェブ ブラウザーに「NoScript」や広告ブロッカーなどのツールがインストールされている場合は、wikipedia.org、wikimedia.org、mediawiki.org、wikidata.org のスクリプトが有効になっていることを確認してください。

利用者スクリプトやガジェットに関連する問題がないかテストする

問題が利用者スクリプトやガジェットに関連しているかどうかをテストするために、一時的にすべてのウィキ上のスクリプトとスタイルシートを無効にしてみるのもいいでしょう。

そのためには、問題が発生しているページのウェブ アドレス (URL) に safemode パラメーター (?safemode=1) を追加してください。 例: https://www.mediawiki.org/wiki/Help:Locating_broken_scripts?safemode=1

URLに既に ? が含まれている場合は、代わりに &safemode=1 を追加します。 例: https://www.mediawiki.org/w/index.php?title=Help:Locating_broken_scripts&safemode=1

セーフモードでテストしているページでも問題が解決しない場合、そしてブラウザーが最新のものである場合は、MediaWiki の開発者に連絡してください (バグの報告方法)。 セーフモードを使用して問題が解消された場合、それは利用者スクリプトやガジェットに問題がある可能性があります。 問題の特定を行う必要があります。

ブラウザーの拡張機能に関連する問題があるかどうかをテストする

Some issues may be a result of interaction between Wikipedia and some browser extension. The easiest way to test it, is to try the same action with all extensions disabled, and the easiest way to achieve this, at least with the Google Chrome and Firefox browsers, is to repeat the operation using "anonymous browsing" or "guest mode", where the browser disables all extensions by default. If the issue disappears with anonymous browsing, try to narrow it down by temporarily disabling extensions one by one, until the "culprit" extension is found.

If you find that the problem is indeed related to a browser extension, consider reporting it to the extension developers. If you decide to report it on a discussion forum on Wikimedia wikis, please mention your browser extension in your report.

問題点の洗い出し

The following links explain how to do this for the following browsers:

After opening them, please append ?debug=true to the web address (URL) of the page on which you see the problem. 例: https://www.mediawiki.org/wiki/Help:Locating_broken_scripts?debug=true

If the URL already includes a ?, append &debug=true instead. 例: https://www.mediawiki.org/w/index.php?title=Help:Locating_broken_scripts&debug=true

If there is a problem with JavaScript, an error should be printed in the 'console' of the developer tools.

Make sure that "JavaScript" or "JS" is enabled here, and potentially disable other output so the output does not get too noisy:

 
Example of results on a wiki, using Firefox debugging mode.

Click on the file name on the right. This will open the "Debugger" view. The right pane will show the code which needs to be fixed. The left pane will show which file needs to be fixed (you might need to scroll through the list to find the one file that is highlighted). Right-click on the file, to open the file that needs fixing in a new tab:

 
Example of results on a wiki, using Firefox debugging mode.

Due to how files are "loaded", the exact URL of the file might not always be obvious. So you may have to scroll to the top of the file to see its name.

This name may just be a comment (something like // Title).

Problems that need fixing could be in the local MediaWiki:Common.js file on that wiki, in your personal files such as User:MyUserName/common.js (or other .js files that you have under User:MyUserName/), or in the code of one of the gadgets available on that wiki, or in the code dependency definitions of the gadget defined in MediaWiki:Gadgets-definition on that wiki.

For more technical information you can check how to Toggle debug mode.

問題点を解決する

You will find most of the scripts by looking in m:Special:MyPage/global.js on Meta, and locally Special:MyPage/common.js, Special:MyPage/vector.js (or similarly named pages, if you are using a different skin, such as Special:MyPage/monobook.js if you are using the MonoBook skin), and anything that is selected locally in the Special:Preferences#mw-prefsection-gadgets.

Problem on scripts can be due to multiple causes. We advise you to contact someone who knows JavaScript to help you. (If you have basic technical knowledge of JavaScript, see T164242 for hints and links to additional information.)

In the meantime, you can disable the scripts.

If the broken script is identified as a gadget, disable the gadget in your preferences.

If the broken script is on a .js page of yours, disable the script by commenting it out. Add /* at the beginning of the concerned code and */ at the end.

You can also disable the script by blanking all of the lines about it in your .js page or by commenting out by // at the start of each line concerned.

壊れたスクリプトを特定するその他の方法

  1. note the gadgets and scripts you are using on your account
  2. disable all scripts and gadgets on your account
  3. re-enable one gadget
  4. clear your browser cache
  5. test if you still have problems:
    • If not, go to step 3
    • If yes, fix the script and go back to step 3 for other potentially broken scripts

Totally unrelated gadgets can break the strangest things. To narrow it down turn off all the gadgets in a particular section of the gadgets list in preferences, and see if that helps. Then if that doesn't work try turning off another section of gadgets. Eventually you will find the section of gadgets where the problem lies. Then turn off the gadgets in that section one by one. Before doing any of this take a screenshot of the whole gadget preferences page. This way you can get back to what you like. Firefox has a built-in screenshot tool that lets you get the whole page including the part of the page not showing on the screen.

関連項目