使用者:BlackShadowG/StubSorter

維基百科,自由的百科全書
StubSorter
描述用於分類小作品
作者
狀態穩定
更新2023年10月1日(7個月前)
瀏覽器支持所有現代瀏覽器,或IE 11
皮膚支持除Minerva外所有皮膚
源碼User:BlackShadowG/StubSorter.js

StubSorter是可輕鬆分類小作品的腳本。它提供了一個類似HotCaT的搜索框來搜索和添加Category:小作品訊息模板中的模板,也可刪除條目已有的小作品模板。

當你點開一篇處於積壓工作分類Category:小作品的條目時,腳本界面會自動打開,其它頁面則需要點擊頁面右上角的「更多」下拉菜單,找到「小作品分類」按鈕(默認,可修改)。同時為了省去另一次點擊,當你添加另一個小作品模板並保存時,{{stub}}會自動刪除。

保存的捷徑是Alt+⇧ Shift+SAlt+S(Mac是Control+⌥ Option+S

啟用

將下列代碼加入你的common.jsskin.js頁面中:

importScript('User:BlackShadowG/StubSorter.js'); // [[User:BlackShadowG/StubSorter]]

搜索模式

StubSorter會搜索Category:小作品訊息模板中的模板。

  • 前綴匹配(prefix):搜索結果來自分類中搜索prefix:"Template:您输入的搜索词"的結果。
  • 標題內匹配(intitle):搜索結果來自分類中搜索intitle:"您输入的搜索词"的結果。

請注意,前綴匹配的所有搜索結果不會出現在標題內匹配的搜索結果中。這是因為標題內搜索尋找的是全詞匹配,而前綴搜索則樂意匹配部分詞。例如,「jap」的標題內搜索不會找到「Japan-stub」,而前綴搜索會找到。「bio」的標題內搜索會找到「Japan-bio-stub」,前綴搜索則不會。

當你搜索時,前綴匹配和標題內匹配的結果都會被檢索出來。默認情況下,前綴匹配會優先顯示。你可以使用下拉菜單進行更改。

  • 優先列出前綴匹配(prefix):將前綴匹配的結果列在標題內匹配上方
  • 優先列出標題內匹配(intitle):將標題內匹配的結果列在前綴匹配上方
  • 嚴格匹配(regex):嚴格匹配模板名稱中的字符序列。This will find all the prefix matches and intitle matches, plus some more. Done internally by querying the search results for intitle:/searchString/。任何正則表達式特殊字符都會被轉義。

默認模式是第一種。你可以將以下代碼添加到您的common.js頁面來修改默認模式:

StubSorter_searchBy = "searchMode"

searchMode替換成prefixintitleregex,各自對應的模式上方的括號中的標註。

鎖定按鈕

The "Freeze" button freezes the search results in place so that any more changing of the search query doesn't change the available options. Rather, the existing options are searched. This can be handy in situations where you want to do a search to filter the list of available templates, and then do another search to find the template from the filtered list.

As a bonus, freezing the menu will silently add extra results to the dropdown for the current search query, upto 500 prefix matches and 500 intitle matches. Otherwise, only upto 100 prefix and intitle matches each are shown.

自定義

監視

默認情況下,您分類的小作品頁面將不會被添加到你的監視列表中。如要自定義,請在您的common.js中添加以下一行代碼:

StubSorter_watchlist = "watch";

該值可以是:

  • watch」 - 將頁面加入監視列表
  • nochange」 - (默認)不改變頁面的監視狀態(無論頁面是否被監視都會維持原樣)
  • preferences」 - 監視列表將取決你的偏好設置:Special:Preferences#mw-prefsection-watchlist-pageswatchlist
  • unwatch」 - 若頁面已加入監視列表,則取消監視(不推薦)

小編輯

默認情況下,您的編輯被標記為小編輯。如要禁用,請添加:

StubSorter_minor = false;

菜單位置

默認情況下,打開此腳本界面的「小作品分類」按鈕在頁面右上角的「更多」下拉菜單(p-cactions菜單)中。您可以通過添加以下代碼,並根據en:Help:Customizing toolbars填入其他portletId以將於置於其他菜單中:

StubSorter_portlet = "portletId";