├── package.json ├── .github └── workflows │ └── build.yml ├── src └── main.js └── README.org /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-github-actions", 3 | "repository": "forsakeninfinity/test-github-actions", 4 | "homepage": "https://github.com/forsakeninfinity/test-github-actions", 5 | "scripts": { 6 | "build": "uglifyjs lib/dexie.js lib/dexie-export-import.js lib/download.js src/main.js -o dist/yomichan-data-exporter.min.js" 7 | }, 8 | "devDependencies": { 9 | "uglify-js": "3.17.4" 10 | }, 11 | "dependencies": { 12 | "dexie": "3.2.4", 13 | "dexie-export-import": "4.0.7", 14 | "downloadjs": "1.4.7" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Download dependencies and build a combined, minified source for release 2 | 3 | on: 4 | push: 5 | 6 | jobs: 7 | build: 8 | permissions: 9 | contents: write 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | 14 | - name: Install dependencies 15 | run: | 16 | npm install 17 | mkdir lib dist 18 | mv node_modules/dexie/dist/dexie.js lib/dexie.js 19 | mv node_modules/dexie-export-import/dist/dexie-export-import.js lib/dexie-export-import.js 20 | mv node_modules/downloadjs/download.js lib/download.js 21 | 22 | - name: Minify and combine source code 23 | run: | 24 | npm run build 25 | 26 | - name: Release 27 | uses: softprops/action-gh-release@v2 28 | if: startsWith(github.ref, 'refs/tags/') 29 | with: 30 | files: dist/yomichan-data-exporter.min.js 31 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 3 | typeof define === 'function' && define.amd ? define(factory) : 4 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.exportDatabase = factory()); 5 | })(this, (function () { 6 | function getSettingsExportDateString(date, dateSeparator, dateTimeSeparator, timeSeparator, resolution) { 7 | const values = [ 8 | date.getUTCFullYear().toString(), 9 | dateSeparator, 10 | (date.getUTCMonth() + 1).toString().padStart(2, '0'), 11 | dateSeparator, 12 | date.getUTCDate().toString().padStart(2, '0'), 13 | dateTimeSeparator, 14 | date.getUTCHours().toString().padStart(2, '0'), 15 | timeSeparator, 16 | date.getUTCMinutes().toString().padStart(2, '0'), 17 | timeSeparator, 18 | date.getUTCSeconds().toString().padStart(2, '0') 19 | ]; 20 | return values.slice(0, resolution * 2 - 1).join(''); 21 | } 22 | 23 | function progressCallback ({totalRows, completedRows}) { 24 | console.log(`Progress: ${completedRows} of ${totalRows} rows completed`); 25 | } 26 | 27 | async function exportDatabase() { 28 | const db = await new Dexie('dict').open(); 29 | blob = await db.export({progressCallback: progressCallback}); 30 | download(blob, `yomichan-dictionaries-${getSettingsExportDateString(new Date(Date.now()), '-', '-', '-', 6)}.json`, 'application/json'); 31 | } 32 | 33 | return exportDatabase; 34 | })); 35 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | #+title: Yomichan Data Exporter 2 | 3 | * Background 4 | 5 | [[https://github.com/FooSoft/yomichan][Yomichan]] is a very cool pop-up dictionary for web browsers. However, it has 6 | been sunset. 7 | 8 | [[https://github.com/yomidevs/yomitan/][Yomitan]] is a fork of Yomichan by [[https://github.com/yomidevs][Yomidevs]] which is actively maintained. 9 | 10 | Migration from Yomichan to Yomitan is going to require people to be able to 11 | move their dictionaries (of which there could be numerous) from Yomichan into 12 | Yomitan. Yomichan lacks export support for dictionaries so people would have to 13 | track down the individual dictionaries they imported and re-import them. This 14 | has in fact been a sore point without concerning Yomitan as Yomichan has always 15 | missed the migration story for when people want to move between devices or 16 | browsers because dictionaries had to be imported one at a time every time. 17 | 18 | Yomitan supports exporting and importing the 19 | entire collection of dictionaries. However, the existing Yomichan extension installations don't have 20 | the code that lets you export the database. Which means that we have no choice 21 | but to inject and run the code on top of the extension somehow. This repository 22 | is just to provide a method that works without much headache for the end-user 23 | to that end. 24 | 25 | * Steps to export the data 26 | 27 | ** On Firefox 28 | + Open Yomichan's setting page (click the gear icon from Yomichan's popup) 29 | + Open the web developer onsole 30 | - Hit =F12= or =CTRL + SHIFT + I= on Windows and Linux; =CMD + OPT + I= on MacOS 31 | + Switch to the =console= tab 32 | + Paste the following into the console and wait for the export + download to 33 | finish: 34 | #+begin_src js 35 | fetch("https://github.com/yomidevs/yomichan-data-exporter/releases/latest/download/yomichan-data-exporter.min.js") 36 | .then((resp) => resp.text()) 37 | .then((srcText) => { 38 | eval(srcText); 39 | }) 40 | .then(async () => await exportDatabase()) 41 | .catch((e) => console.error(e)); 42 | #+end_src 43 | + If you run into errors for the above somehow, try the same steps as Chrome below. 44 | 45 | ** On Chrome 46 | + Open Yomichan's setting page (click the gear icon from Yomichan's popup) 47 | + Open the web developer onsole 48 | - Hit =F12= or =CTRL + SHIFT + I= on Windows and Linux; =CMD + OPT + I= on MacOS 49 | + Switch to the =console= tab 50 | + Unfortunately(?!), Yomichan released on Chrome doesn't have permission to 51 | actually inject code (I tried a whole bunch of different approaches and the 52 | permissions are just lacking) so you are going to have to paste the contents 53 | of the [[https://github.com/yomidevs/yomichan-data-exporter/releases/latest/download/yomichan-data-exporter.min.js][exporter code]] into the console. 54 | 55 | It is a very long "one-liner" and apparently github is pretty bad at handling 56 | all of it being put into a code box so you may want to open the raw file, 57 | select all, then copy and paste into the console. [[https://github.com/yomidevs/yomichan-data-exporter/releases/latest/download/yomichan-data-exporter.min.js][Link to the raw]]. 58 | 59 | + Finally, paste the following into the console and wait for the export + 60 | download to finish: 61 | #+begin_src js 62 | await exportDatabase(); 63 | #+end_src 64 | 65 | * Steps to import the exported Yomichan dictionaries data 66 | 67 | You can actually import the exported dictionaries into existing installations 68 | of Yomichan, but it is going to require similarly annoying console one-offs. 69 | 70 | Instead, I strongly recommend migrating to [[https://github.com/yomidevs/yomitan/][Yomitan]] where there is first-class support for importing (and 71 | exporting) this data in the =Backup= section of the settings page. The UI there 72 | should be self-explanatory, but refer to the [[https://yomitan.wiki/other/yomichan-migration/][Yomitan documentation page]] 73 | and Yomitan's welcome page for more information. 74 | 75 | * Dependencies 76 | 77 | ** dexie 3.2.4 78 | 79 | + Source Repository: https://github.com/dexie/Dexie.js 80 | + APACHE LICENSE: https://unpkg.com/browse/dexie@3.2.4/LICENSE 81 | 82 | ** dexie-export-import 4.0.7 83 | 84 | + Source Repository: https://github.com/dexie/Dexie.js/tree/master/addons/dexie-export-import 85 | + APACHE LICENSE: https://unpkg.com/browse/dexie-export-import@4.0.7/LICENSE 86 | 87 | ** downloadJS 4.21 88 | 89 | + Source Repository: https://github.com/rndme/download 90 | + MIT LICENSE: https://github.com/rndme/download/blob/master/LICENSE.md 91 | --------------------------------------------------------------------------------