Kuju29 / Translate-image-manga-In-Page

0 stars 0 forks source link

Translate Images in Manga In-Page "Extension" and "Program"

Watch the Demo

I created this extension for personal use, but feel free to take this idea and improve upon it. The project was built entirely using ChatGPT, and while some of the code may be unnecessary, I decided to leave it as is for now. Future updates will refine and optimize the code further.

I have made two versions: 'Translate-image-manga-In-Page,' which is an extension that requires the Google API and comes with costs, and 'ghostmanga.py,' which is a script with a UI that's free and easy to use. The details are below. I created them because they share the same code structure but are used differently. I hope everyone will like them.

Working Principle

This Chrome extension finds the URLs of images on a page using a specified class, performs OCR (Optical Character Recognition) on those images, translates the text, and replaces the original images with new, translated versions.


Requirements

  1. Google Chrome
  2. Go to API & Services > Library in the Google Cloud Console.
    • Search for Vision API and click to enable it.
  3. fter enabling the APIs, go to API & Services > Credentials to create your API key:
    • Click on Create Credentials.
    • Select API Key.
    • Copy the API Key and save it securely.
  4. Ensure all images have the same class. This extension cannot be used on websites that use blob images and Protected websites.

Download & Setup

  1. Download the extension
  2. Unzip the downloaded file: Translate-image-manga-In-Page-main.zip

Installation Steps

  1. Open Chrome and go to chrome://extensions/
  2. Enable Developer Mode
  3. Cilck Load unpacked
  4. Select Folder Translate-image-manga-In-Page-main
  5. Done! Your extension is ready to use.

If you want the extension to not disappear when the folder is deleted or moved:

  1. Go to Translate-image-manga-In-Page folder
  2. Compress all the files inside, including any subfolders, into a .zip file.
  3. Drag the .zip file into chrome://extensions/
  4. Done.

Version Updates


CSS Selector Guide

Below are common CSS selectors and their abbreviations, which the extension uses to find and manipulate images:

Full Form (HTML Attribute) Abbreviation (CSS Selector)
[class="image-container"] .image-container
[id="main-header"] #main-header
[rel="stylesheet"] link[rel="stylesheet"]
[href="https://example.com"] a[href="https://example.com"]
[type="submit"] input[type="submit"]
[role="navigation"] [role="navigation"]
[data-toggle="dropdown"] [data-toggle="dropdown"]
[alt="Image description"] img[alt="Image description"]
[src^="https://"] img[src^="https://"]
[name="email"] input[name="email"]
[value="Search"] input[value="Search"]
[class="image-container"] > img .image-container > img
[class="button primary"] > span .button.primary > span
div[class="content"] p div.content p
[class="nav"] ul > li[class="nav-item"] .nav ul > li.nav-item
[class="menu-item"] a:hover .menu-item a:hover
[class="form-group"] input[type="text"] .form-group input[type="text"]
[class="gallery"] div[class="gallery-item"] .gallery div.gallery-item

If you want to search for all the images on the page, you can use the selector as just 'img', as shown in the image. image


image


Screenshots

image image image


Ghost Manga

Ghost Manga UI v2.2.0 (This version still has a problem with slow program closing. I will fix it later.): https://www.mediafire.com/file/ftjnwukhpb4h0qx/Ghost_Manga_UI_v2.2.0.exe/file\ Ghost Manga UI All version: https://www.mediafire.com/folder/s6ecg0np9f6gj/Ghost+manga

image