Skip to content

maanimis/MetaTranslator

Repository files navigation

MetaTranslator

This is a project help you build userscript with webpack

Just use this git repo as a template.

Install

  1. Install one of the Violentmonkey or Tampermonkey extensions (available for all browsers).
  2. Go to the Releases section, where you'll find a .js file.
  3. Click the file to install it, and you're all set!

How to Use:

  • Simply select any text with your mouse, and it will be automatically translated.

dependencies

There are two ways to using a package on npm.

UserScript way

like original UserScript way, you will need to add them to your user script metadata's require section , and exclude them in config/webpack.config.base.cjs

Webpack way

just install packages with npm and import them in your code, webpack will take care them.

Build

npm run build

dist/index.prod.user.js is the final script. you can manually copy it to greasyfork for deploy.

Minify

There is a limitation in greasyfork, your code must not be obfuscated or minified.

If you don't need to deploy your script to greasyfork, enable minify as you like.

automatically Deploy

github actions will deploy production userscript to gh-pages branch.

example

deployed

You can auto use greasyfork's auto update function.

Q&A

you may find enabling source map not working well in production code, because Tampermonkey will add extra lines (all your @require) before your script. I don't know if there is a good fix for this, You need to use webpack config devtool with eval prefix to make it work as expected, so source map is disabled in this production build.

https://webpack.js.org/configuration/devtool/#development

About

Show translated tooltip on text selection

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •