Help:Locating broken scripts/zh

如果您在使用本地小工具或使用者腳本時遇到問題，那麼這些問題通常是由損壞的JavaScript程式碼（編寫小工具所使用的程式語言）或其他程式碼的未聲明依賴關係所造成.

要找尋有問題需要修復的程式碼和位置，您將需要使用網頁瀏覽器的開發人員工具，結合該工具和特殊的URL來使用，將能幫助您找出損壞的腳本.

確保您有最新的配置
首先，請確保您的瀏覽器是最新版本. 因為安全原因，舊版瀏覽器不支持MediaWiki的功能和某些腳本.

然後，清除頁面的緩存，以強制頁面根據原始碼來重新顯示或重新啟動腳本.

這兩點能解決大多數的問題.

如果您在網頁瀏覽器上安裝了「NoScript」之類的工具或廣告攔截器，請確保已為wikipedia.org、wikimedia.org、mediawiki.org和wikidata.org啟用了腳本.

測試您是否遇到與使用者腳本或小工具有關的問題
要測試您的問題是否與使用者腳本或小工具相關，您可以嘗試暫時停用所有維基上的腳本.

要這麼做，在您遇到問題的頁面網址（URL）加入 ，例如：

如果URL已經包含 ，則附加 ，例如：

如果您使用安全模式進行測試且瀏覽器是最新版，卻仍然在頁面上遇到問題，請與MediaWiki的開發人員聯繫（如何報告錯誤）. 如果使用安全模式就不再有問題，則表示使用者腳本或小工具存在問題. 您需要找出問題所在.

測試您是否遇到與瀏覽器擴充功能相關的問題
某些問題可能因為維基百科和某些瀏覽器擴充功能間相互影響造成的結果. 最簡單的測試方法是，在停用所有擴充功能的情況下嘗試相同的操作. 要實現此操作的最簡單方法是，在google chrome和firefox瀏覽器中使用「匿名瀏覽」，其在預設情況下是停用所有擴充功能的. 如果該問題在匿名瀏覽中消失了，請嘗試逐個暫時停用擴充功能來縮小範圍，直到找到是「罪魁禍首」的擴充功能.

如果您發現問題確實與瀏覽器擴充功能有關，請考慮將其報告給該擴充功能的開發人員. 如果您決定在維基百科上進行報告，請在報告中提及這個事實.

找出問題
以下連結說明了如何在這些瀏覽器中進行此操作：Chrome/Chromium、Firefox、Internet Explorer、Opera和Safari.

在打開它們之後，請在您看到問題的頁面網址（URL）後附加 ，例如：

If the URL already includes a , append  instead. Example:

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:



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:



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 ).

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 ), 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.

Fix the problem
You will find most of the scripts by looking in m:Special:MyPage/global.js on Meta, and locally, 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.

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 or 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.

Other ways to identify broken scripts

 * 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 cache
 * 5) test if you still have problems:
 * 6) * If not, go to step 3
 * 7) * 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.

参见

 * ResourceLoader/Architecture § Disable on a single page