GitHub
Nhật trình
Mã nguồn
Tệp worker
Biên dịch
Định kiểu
Sử dụng
Tuỳ chọn

JavaScript Wiki Browser là một kịch bản người dùng có thể thực hiện nhanh chóng các sửa đổi bán tự động. Nhìn chung, công cụ này tương đồng với phần mềm AutoWikiBrowser và có một số tính chất dựa trên AWB, như thiết kế, chức năng sửa chính tả bằng regex và dùng chung danh sách kiểm tra quyền truy cập nhưng không yêu cầu tải xuống, cũng như có thể chạy trên mọi hệ điều hành lớn. Để sử dụng, bạn cần có tên trong danh sách sử dụng AWB, hoặc có quyền bảo quản viên.

Cài đặt sửa

Trước khi sử dụng, bạn cần cài đặt bằng cách thêm dòng dưới đây vào trang common.js:

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Joeytje50/JWB.js/load.js&action=raw&ctype=text/javascript');
hoặc
{{thế:lusc|en:User:Joeytje50/JWB.js/load.js}} (bỏ qua cảnh báo lỗi khi lưu)

Lưu ý: Để sử dụng, bạn phải có tên trong danh sách kiểm tra quyền truy cập AWB, nếu trang đó tồn tại. Nếu không có trang nào như vậy, mọi người dùng đã đăng ký đều có thể sử dụng công cụ này.

Bắt đầu sửa

Sau khi cài đặt, hãy truy cập trang này để khởi động công cụ.

Tuy giao diện của JWB hơi hẹp, nhưng bạn sẽ dần quen nếu thường xuyên sử dụng. Thiết kế này sẽ hạn chế số thẻ cần sử dụng, từ đó giúp bạn làm được nhiều việc hơn mà không cần đổi thẻ liên tục.

Bộ phận quan trọng nhất của công cụ là danh sách trang; bạn có thể thêm tuỳ ý các trang vào vùng trắng ở góc dưới bên trái màn hình. Danh sách trang, cùng với khu vực sửa đổi và hộp kết quả (đầu trang) có thể co giãn.

Khi sửa đổi, mọi biểu mẫu đầu vào sẽ bị tắt, nên nếu muốn sửa thiết lập, bạn cần dừng công cụ lại trước.

Danh sách trang sửa

 
Tuỳ chọn thiết lập

Thẻ đầu tiên (Setup) có một số tuỳ chọn áp dụng cho danh sách trang. Nút Remove duplicates sẽ tự động gỡ bỏ các trang trùng lặp, còn nút Sort sẽ sắp xếp tên trang theo thứ tự bảng chữ cái.[1]

Biến trang sửa

Bạn có thể chỉ định biến cho trang trực tiếp trong danh sách trang bằng cách thêm | và giá trị biến đó vào sau tên trang. Sau đó, các hộp Replace, With, Skip when… và, với bảo quản viên, New pagename sẽ có thể sử dụng biến này thông qua hai ký tự thay thế $x.

Biến này sẽ rất hữu ích khi di chuyển nhiều trang cùng lúc, sửa các từ khác nhau ở nhiều trang, hay khi cần thay nội dung gì đó bằng một từ cụ thể. Chẳng hạn, hãy xếp tên cũ và tên mới cạnh nhau, cách nhau một dấu | rồi thêm $x vào ô New pagename; khi di chuyển, JWB sẽ tự động di chuyển trang đến tên mới đã định. Nếu biến không được chỉ định, nó sẽ nhận giá trị mặc định là tên trang đó.

Phân tích trước sửa

Chế độ phân tích trước giúp tự động lọc danh sách các trang, chỉ để lại những trang không đáp ứng điều kiện bỏ qua. Để kích hoạt, hãy chọn ô Use pre-parse mode và chỉ định điều kiện trong thẻ Skip; sau đó, nhấp Start. JWB sẽ bỏ qua trang, hoặc đưa nó xuống cuối danh sách để sử dụng sau.

JWB sẽ tự động thêm một dòng #PRE-PARSE-STOP vào cuối danh sách để biết khi nào cần dừng lại. Nếu bạn muốn thay đổi điểm dừng, hãy thêm #PRE-PARSE-STOP vào ngay bên dưới trang cuối bạn muốn phân tích trước, giống như với một trang bình thường.

Bạn có thể dừng lại quá trình phân tích trước bất cứ lúc nào; #PRE-PARSE-STOP sẽ không mất đi. Bạn có thể thay đổi điều kiện bỏ qua, hoặc nhấp nút reset bên cạnh ô Use pre-parse mode để tái khởi động quá trình phân tích trước.

Tạo danh sách trang sửa

Để tạo danh sách trang, hãy nhấp vào nút Generate trong thẻ Setup để khởi động cửa sổ tuỳ chọn tìm kiếm. Nhằm tránh gây quá tải máy chủ, bạn chỉ có thể chạy tối đa 50 truy vấn cùng lúc. Số trang tối đa trên mỗi truy vấn phụ thuộc vào tuỳ chọn và tài khoản bạn sử dụng: Với tuỳ chọn "Trang trong thể loại", giới hạn là 500 (5000 với bot), còn các tuỳ chọn khác là 50 (500 với bot).

Mỗi tuỳ chọn tìm kiếm sẽ lọc kết quả dựa trên các không gian tên bạn chọn từ danh sách bên phải cửa sổ con. Nhấn Ctrl hoặc Shift và nhấp hoặc kéo thả để chọn nhiều không gian tên. Nếu số trang được tạo lớn hơn giới hạn tối đa, bạn có thể dùng tính năng này để lọc bớt kết quả.

Để kích hoạt một tuỳ chọn đơn lẻ, hãy đánh dấu vào ô phía trên nó và ngược lại.

Trang trong thể loại
Lấy danh sách các trang trong thể loại chỉ định.
Để loại trừ các thể loại con, tập tin và/hoặc trang thông thường, hãy bỏ đánh dấu ở hộp tương ứng.
Liên kết đến trang
Lấy danh sách các trang liên kết đến trang chỉ định.
Ba ô tuỳ chọn đầu tiên lần lượt sẽ tìm liên kết wiki, nhúng bản mẫu và nhúng tập tin; bạn có thể kích hoạt tất cả cùng lúc. Ba nút điều hướng ở dòng thứ hai giúp lọc ra liên kết từ trang không đổi hướng, từ trang đổi hướng và không lọc. Ô cuối cùng cho phép tìm liên kết đến cả các trang đổi hướng đến trang bạn nhập vào; nghĩa là, nếu bạn tìm liên kết đến trang A, trang B đổi hướng đến trang A, và trang C liên kết đến trang B, thì trang C sẽ được thêm vào danh sách kết quả tìm kiếm.
Trang có tiền tố
Lấy danh sách các trang có tiền tố chỉ định.
Nếu chế độ strict được bật, kết quả trả về sẽ bao gồm mọi trang bắt đầu với chính xác cụm đã nhập. Nếu không, JWB sẽ tìm fuzzy (engine_autoselect).
Danh sách theo dõi
Lấy danh sách các trang trong danh sách theo dõi của bạn.
Liên kết khỏi trang
Lấy danh sách các trang liên kết từ trang chỉ định.
Tuỳ chọn này sẽ hữu ích ở các trang sử dụng trình tạo danh sách trang phức tạp như DynamicPageList.
Tìm kiếm
Lấy danh sách các trang tìm được thông qua hộp tìm kiếm thông thường.
Bạn nên giới hạn kết quả bằng cách sử dụng CirrusSearch: hãy dùng insource:/ví dụ/ hoặc intitle:/ví dụ/ thay cho ví dụ.
Tìm kiếm MediaWiki Ngữ nghĩa
Lấy danh sách các trang tìm được thông qua truy vấn SMW.
Ở các wiki có cài phần mở rộng MediaWiki Ngữ nghĩa (SMW), một hộp tìm kiếm bổ sung sẽ xuất hiện ở dưới cùng, cho phép bạn nhập vào một truy vấn SMW. Nếu truy vấn có bao gồm một thuộc tính cụ thể, thuộc tính đầu tiên được trả về (bỏ qua các thuộc tính khác) sẽ được coi là biến trang và bạn sẽ có thể sử dụng nó thông qua $x. Chẳng hạn, Thể loại:Vật liệu|?nhiệt độ nóng chảy sẽ tạo một danh sách vật liệu (Q214609) và thuộc tính nhiệt độ nóng chảy (P2101) của chúng.
Vì truy vấn SMW và các truy vấn khác sẽ chạy tách biệt với nhau, nếu sử dụng chúng cùng lúc, danh sách có thể sẽ có một số trang trùng lặp. Hãy lọc các trang đó ra bằng cách sử dụng nút Remove duplicates ở thẻ Setup.

Lưu ý: Nếu bạn chọn đồng thời nhiều tuỳ chọn tìm kiếm, kết quả sẽ là hợp của các danh sách: tìm theo "Trang có tiền tố" và "Trang trong thể loại" sẽ cho kết quả là các trang nằm trong thể loại chỉ định hoặc bắt đầu bằng tiền tố đã cho.

Giới hạn sửa

In the Setup tab, below the page list and settings options, you can set limits to JWB. Using these limits, you may restrict the amount of time taken by JWB on any one find&replace rule, or the amount of characters added or removed by any one edit. Note that setting a diff size limit does not give any guarantees about the quality of your edit. Do not solely rely on this setting to prevent your find&replace rules from behaving unexpectedly. This is intended only as a form of 'insurance' that your edits will not add or remove unexpected amounts of text from a page.

Bỏ qua sửa

 
Skip options

Using the Skip tab, you can set several rules for which pages should be skipped automatically.

Đổi hướng
You can either select to follow redirects and edit the page the redirect leads to (this will also follow double redirects), or edit the redirects themselves. You can also select to skip redirect pages altogether.
Không có thay đổi
If you select to skip when no changes are made, the page will automatically skip when the defined find & replace rules don't apply any changes to the page.
Tồn tại hoặc không
You can either select to skip when the page exists, skip when it doesn't exist, or edit both existing and non-existing pages.
Nội dung
You can skip either when the page contains a certain string, or when it doesn't contain that. If the phrase entered in When page contains results in any matches on the page, or if the phrase entered in When page doesn't contain results in no matches, the page will be skipped.
You can either enter a certain keyphrase that should or should not occur on the page, or you can select to use a regular expression. For more information on regular expressions, see #Sử dụng biểu thức chính quy.
Regex matches will only be allocated a limited amount of time if the browser and wiki settings support this feature[2]. The time limit for each individual match rule can be set in the 'Setup' tab.
Thể loại
Pages that contain categories listed here (comma-separated or |-separated) will be skipped automatically.

Sửa đổi sửa

 
Thiết lập sửa đổi
 
JWB ở chế độ Khác
 
JWB ở chế độ Xem trước

In the Editing tab, you can specify the basic settings for editing. You can fill in the summary, and whether or not to mark the edit as 'minor'. The checkbox next to the summary input box toggles whether or not to append (via JWB) to your summary automatically. You can also select what to do to your watchlist. You can either select to add or remove every page you edit to or from your watchlist, not to modify your watchlist, or to watch pages based on your preference settings.

While editing, you can also directly add or remove pages to or from your watchlist by pressing the button next to the watchlist dropdown. The button will be labelled with what action it will trigger (either adding or removing).

Every page will automatically display the difference between the stored content, and the content after the find & replace rules are applied. You can also press nút Preview to see the generated output. Some styles may not be loaded in this view though, since JWB uses a page structure different from the normal page contents. This may cause styles that depend on the position in the document not to function anymore.

Users with the bot usergroup, that are also listed on the wiki's AutoWikiBrowser checklist under the 'bot' category, will also be able to automatically save their edits. This can be done with a throttle to prevent overloading the server. The number entered in the "every [] sec" field is the number of seconds between edits. This number can also contain decimals (dấu thập phân là dấu .).

Thay thế sửa

Tính năng chính của JWB là thay thế tự động/bán tự động. Quy tắc thay thế được chỉ định bằng thanh quy tắc trong thẻ Editing. Ở chế độ thường, JWB sẽ thay thế mọi cụm từ bắt được, tức là: Nếu bạn chỉ định thay a bằng b, JWB sẽ thay mọi a trong trang bằng b. Để chỉ thay thế lần xuất hiện đầu tiên, hãy bật chế độ biểu thức chính quy (escape các ký tự đặc biệt nếu cần thiết) và bỏ cờ g đi.

Để thêm dòng mới, hãy dùng ký tự \n ở vị trí muốn xuống dòng. Với dấu \, bạn cần escape nó như sau: \\.

Regex replacements will only be allocated a limited amount of time if the browser and wiki settings support this feature.[2] The time limit for each individual regex replacement rule can be set in the 'Setup' tab. This feature prevents freezing up the entire tool when a regex takes too long to execute.

Sửa chính tả sửa

You can use danh sách lỗi chính tả cho AWB to automatically fix any typos that exist on the page. Keep in mind that you must always check if the automatic fixes are correct. These automatic fixes will not be applied to image names, template names and parameters,[3] quotes,[4] and any text following a colon or asterisk, as well as skipping any rule that also matches a wikilink target. Any lines of text that contain a {{sic}} indicator will also be ignored by this typo fixer.[5] These rules are taken from the rules listing for AWB.

Note: Due to some browsers not supporting Regex lookbehinds, it is recommended to run this feature of JWB from one of the supporting browsers. At the time of writing, this includes Google Chrome, Firefox, and Opera. Note that even for browsers that support it, older versions may not have, and users should check if they are using an up-to-date version or else not be able to perform as many typo fixes as other browsers.

Do note that this uses the typo list on the wiki the script is executed from. If you are using this script on a wiki which has no Project:AutoWikiBrowser/Typos page, typo fixing will not work.

If you wish to disable RETF for a single page, you can use the button below the RETF checkbox to reload the page contents without RETF applied to it. This can be useful when editing pages with intentional misspellings or old language, for example. To re-apply RETF again after having disabled it, simply stop and restart JWB to re-apply automatic replacements as usual, including RETF.

Sử dụng biểu thức chính quy sửa

Ngoài tính năng tìm và thay thế thông thường, bạn cũng có thể sử dụng biểu thức chính quy. Here you have more control over what gets matched, and what doesn't. You can specify the flags you'd like to use in the box next to the Regular Expression checkmark.

JWB có một cờ đặc biệt: _. Cờ này sẽ khiến biểu thức coi mọi dấu cách và gạch dưới như nhau, rất hữu ích nếu bạn muốn xử lý liên kết wiki, bản mẫu nhúng hay tương tự.

Nếu muốn thay thế với nhiều quy tắc trên cùng một trang, hãy nhấp vào nút More replace fields để mở cửa sổ quy tắc; các thanh quy tắc này có chức năng tương tự như thanh quy tắc chính ở thẻ Editing. Bạn có thể dùng nút Add more fields hoặc nhấn Tab khi con trỏ soạn thảo đang ở thanh quy tắc dưới cùng để thêm thanh mới.

Để thử nghiệm biểu thức chính quy (tất nhiên, không có cờ _), bạn có thể sử dụng các IDE trực tuyến như regex101.com, debuggex.com, và regexr.com.

Bỏ qua nội dung không được xử lý sửa

Nếu kích hoạt tuỳ chọn này, JWB sẽ chỉ thay thế nội dung nằm ngoài:

  • Bình luận ẩn: <!-- Đoạn này sẽ được bỏ qua. -->;
  • Thẻ mã: <nowiki>, <code>, <source>, <syntaxhighlight><pre>;
  • Thẻ định dạng: <math>, <gallery><timeline>.

Lưu ý: Quy tắc này không giống với quy tắc bỏ qua của RETF: các phần tử như trích dẫn hay liên kết sẽ không được bỏ qua.

Thiết lập sửa

JWB allows you to store your current settings either on the wiki, or on your own computer. You can also temporarily store them during this session by clicking Store setup. That allows you to go back to the temporarily stored settings during this browser session, so that you can for example re-run JWB on a certain page list. To access them in a later session, you have to save them to the wiki, or download them.

Saving to the wiki stores your settings on Special:MyPage/JWB-settings.json. Settings from this page are also automatically loaded to JWB when it loads, and the settings named "default" will automatically be applied when it loads. If you've modified your JWB settings on your /JWB-settings.json subpage, you can also refresh them in JWB by clicking the Update button.

You can also download the settings as a JSON file. When saving this file, be sure to specify the file extension .json, otherwise you won't be able to select it via the Import button. You can import files by either clicking Import and selecting the JSON file, or by dragging a JSON file over the JWB window and releasing it (drag & drop). If the file extension is JSON, it will automatically load the settings from the file.

You can also delete a setup from your list by selecting the setup via the dropdown menu, and pressing Delete. If you accidentally clicked this button, you can easily revert the deletion by pressing Undo in the status bar.

As of February 14, 2021, the settings page has moved from "JWB-settings.js" to "JWB-settings.json". If you had a settings page in this old location, this page will automatically be moved to the new location.

Các tác vụ khác sửa

Administrators can also perform other actions on the page. These actions can not be automated, not even on accounts with both bot and sysop rights.

Di chuyển sửa

When moving pages, the move summary used is taken from the Editing tab. You can select to suppress redirect, which prevents the move from leaving a redirect in the place of the old page's title. You can also select to move all subpages and/or the talk page.

Xoá trang sửa

Deleting, like moving uses the summary box for its delete reason.

Khoá trang sửa

For protection, you can specify the protection levels for Editing, Moving and Uploading separately. When the page doesn't exist, the level defined in the Edit protection is instead applied to the Create protection. The Upload protection is only applied to pages where this is applicable (i.e. File pages). The expiry field allows input in the same way as normal time input does. Inputs like "1 hour", "5 January 2000", etc. are allowed here.

Nhật trình sửa

 
Log

Thẻ Log lưu trữ một lịch sử các tác vụ đã thực hiện theo thứ tự thời gian và liên kết đến sửa đổi để bạn có thể tự kiểm tra lại. Thông số chi tiết được ghi lại ở chân trang.

Đóng góp sửa

Nếu biết JavaScript, bạn có thể đóng góp vào mã nguồn JWB.

Chú thích sửa

  1. ^ “Array.prototype.sort()”. MDN Web Docs (bằng tiếng Anh). 12 tháng 1 năm 2022. Truy cập ngày 4 tháng 2 năm 2022.
  2. ^ a b Technical details: Requires browser support for Web Workers and website Content Security Policy allowing script-src: blob:; or worker-src: blob:;
  3. ^ Because of the non-regular nature of wikitext, this script will recognise any closing }} as the end of the outermost template. This means that if a template is nested inside another, and a typo occurs after that nested template, it will not be ignored.
  4. ^ Quotes that are not surrounded by a quotation template (ie. quotes surrounded by plain "") can only span a single line to be recognised. If an opening quote is on one line and the quote isn't ended until the next line, it will not be regarded as a quote, and will not be ignored. Please watch for quotes that do not get recognised manually.
  5. ^ A line where a transcribed typo has already been manually marked will likely have been spell-checked manually before. Chances are that any typo occurring anywhere on the same line of text will also be an intentional or transcribed typo, and therefore should not be fixed.