commit 69e64ac3478196bb217b29799f6be23b32279b82 Author: Alexander Popov Date: Mon May 1 12:09:27 2023 +0300 MAL Parser diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..de5d01c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,28 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.js] +indent_style = space +indent_size = 2 + +[{package*.json,.prettierrc}] +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false + +[{node_modules/**,.git/**}] +charset = unset +end_of_line = unset +insert_final_newline = unset +trim_trailing_whitespace = unset +indent_style = unset +indent_size = unset diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..27c38f7 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +**/.git +**/node_modules diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..a7b6e5e --- /dev/null +++ b/.prettierrc @@ -0,0 +1,10 @@ +printWidth: 100 +endOfLine: lf +useTabs: false +singleQuote: true +bracketSpacing: true +semi: true +overrides: + - files: 'JavaScript/*.{js}' + options: + parser: meriyah diff --git a/JavaScript/mal_parser.js b/JavaScript/mal_parser.js new file mode 100644 index 0000000..8cdef82 --- /dev/null +++ b/JavaScript/mal_parser.js @@ -0,0 +1,43 @@ +/** + * MyAnimeList lists parser + * @author Alexander Popov + * @version 1.0.0 + * @license Unlicense + * url: https://git/a2s.su/iiiypuk/userScripts/JavaScript/mal_parser.js + */ + +let dataElement = document.getElementsByTagName('table'); +let dataItems = JSON.parse(dataElement[0].dataset.items); + +let dataExport = Array(); + +dataItems.forEach((item) => { + let itemData = { + // title: (item.anime_title_eng.trim().length > 0) ? item.anime_title_eng.trim() : item.anime_title, + title: item.anime_title, + type: item.anime_media_type_string, + epCurrent: item.num_watched_episodes, + epTotal: item.anime_num_episodes, + }; + + dataExport.push(itemData); +}); + +/** + * Export items by gemtext syntax + * @param {array} data - The anime data. + */ +function exportForGemini(data) { + let exportArray = Array(); + + data.forEach((i) => { + exportArray.push(`* ${i.title} [${i.type}] [${i.epCurrent}/${i.epTotal}]`); + }); + + exportArray.forEach((line) => { + console.log(line); + }); +} + +console.log(dataExport); +// exportForGemini(dataExport); diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fdddb29 --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/README.md b/README.md new file mode 100644 index 0000000..6fb1e6a --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +## JavaScript + +- [MAL Parser](JavaScript/mal_parser.js) — MyAnimeList lists parser. diff --git a/README.ru.md b/README.ru.md new file mode 100644 index 0000000..8bebae9 --- /dev/null +++ b/README.ru.md @@ -0,0 +1,3 @@ +## JavaScript + +- [MAL Parser](JavaScript/mal_parser.js) — Парсинг списков MyAnimeList. diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..b1ad614 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,27 @@ +{ + "name": "userScripts", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "prettier": "^2.8.8" + } + }, + "node_modules/prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..8e64511 --- /dev/null +++ b/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "devDependencies": { + "prettier": "^2.8.8" + } +}