Website page translation patch

This script is used to fix some problems before the website is translated, such as invalid or missing links, mismatched values ​​in drop-down list boxes due to translation, and the problem of content being piled together because line breaks are lost after translation. Compatible with page content updated dynamically.

Author
龍翔翎
Daily installs
0
Total installs
4,028
Ratings
3 0 0
Version
5.7.0
Created
2022-03-19
Updated
2024-08-31
Size
13.7 KB
License
MIT
Applies to
All sites

Description

This script is used to pre-fix some problems before the website is translated, such as invalid or missing links, mismatched values ​​in drop-down list boxes due to translation, and the problem of content being piled together because line breaks are lost after translation. Compatible with page content updated dynamically.

This script theoretically supports all translation plug-ins that obey with the "translate" attribute, not just Google Translate, but cannot be applied to translation plug-ins that do not obey with the label marked "translate='no'"

How to use

Online play (games from URLs)

Just right-click on a blank space on the page (not on the picture), then find "Tampermonkey", and then click on the option of this script name. When you see "網站頁面翻譯補釘應用成功,可以開始翻譯頁面"(A green tip) AFTER THAT go to translate the page normally. (You still need to start translation yourself, the script cannot automatically call page translation)

Offline play (downloaded game)

By default, Chrome does not allow plug-ins (extensions) to run on local web pages (file:// protocol). Therefore, if you open a downloaded local web page, the Tampermonkey itself may be disabled, so the script inside It won't work of course. You need to enable the local web page access permission of Tampermonkey.

The way is: click the plug-in (extension) icon in the upper right corner of chrome - click the three dots on the right of Tampermonkey - Manage Extensions - Allow access to file URLs - (Restart the browser) This will solve the problem

FAQ

  • I can't find the Tampermonkey option in contextmenu
    • Make sure Tampermonkey is installed correctly
    • If you are playing offline, please follow the Offline play steps to make sure Grease Monkey/Tamper Monkey turns on the "Allow access to file URL" option.
  • I successfully applied the patch, but the page cannot be translated
    • This situation has nothing to do with this script. This script is just for patching and will not hinder translation.
    • If using Google Translate, make sure your Internet connection is working and check if there is any message indicating that the translation failed in the upper right corner.
    • If you play online, most game websites will enclose the game web page in an iframe (even if it seems to filled the page), and any translation plug-in will not be able to translate the page in the iframe. But you can do this: Right-click on a blank space on the game page -> Inspect -> Look up to find the src of the iframe (usually the blue underlined URL) -> right-click -> "Open in new tab" This way You will be able to open the game's original webpage in a new tab, and you should be able to translate it now.
    • Some websites force the page to be opened through their website. Directly opening the iframe link cannot be played. I'll recommended you to change the website directly. This kind of mandatory requirement that the website is set in an iframe cannot be translated, and there is no solution.
    • Generally speaking, this situation does not occur in offline games. If it does, it may be that the game itself uses some iframes. The current mainstream HTML game engines will not do this, but it is not ruled out that a small number of authors use non-mainstream or their own game engines. There is no other way to fix it. Just change the game.
  • Some links changed text automatically, but they no longer changed after applying the patch.
    • The patch uses a method of creating fake links, essentially copying a link when it appears, so it is incompatible with dynamic content, and I currently have no plans to add listener for content changes.
    • The patch will not breaks the function (for example, the automatic text change is for random events, so even if the text remains unchanged after the patch is applied, the event will still be random when clicked)

v5.6

  • Fixed the dynamic translation of Link whose content changes when clicked (some games click on the link to cycle through the text)
  • Instructions for adding "FAQ" section

v5.3

  • Fixed the phenomenon of line breaks disappearing during translation (for example, status and attributes are piled together)

v4.0

  • Modified the running mode: changed from re-traversing elements to queue recursion, avoiding the problem of ID duplication or confusion that may have occurred before. And greatly optimized the performance
  • Fixed the issue where the link would move to the left, now the link will stay in place as much as possible
  • Updated the generation rules for tag attributes, now shorter
  • Modified and added some comments
  • Remove legacy obsolete code

v3.0

  • Add processing for drop-down lists.