MAL Parser

This commit is contained in:
Alexander Popov 2023-05-01 12:09:27 +03:00
commit 69e64ac347
Signed by: iiiypuk
GPG Key ID: E47FE0AB36CD5ED6
9 changed files with 146 additions and 0 deletions

28
.editorconfig Normal file
View File

@ -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

2
.prettierignore Normal file
View File

@ -0,0 +1,2 @@
**/.git
**/node_modules

10
.prettierrc Normal file
View File

@ -0,0 +1,10 @@
printWidth: 100
endOfLine: lf
useTabs: false
singleQuote: true
bracketSpacing: true
semi: true
overrides:
- files: 'JavaScript/*.{js}'
options:
parser: meriyah

43
JavaScript/mal_parser.js Normal file
View File

@ -0,0 +1,43 @@
/**
* MyAnimeList lists parser
* @author Alexander Popov <iiiypuk@fastmail.fm>
* @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);

24
LICENSE Normal file
View File

@ -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 <https://unlicense.org>

3
README.md Normal file
View File

@ -0,0 +1,3 @@
## JavaScript
- [MAL Parser](JavaScript/mal_parser.js) — MyAnimeList lists parser.

3
README.ru.md Normal file
View File

@ -0,0 +1,3 @@
## JavaScript
- [MAL Parser](JavaScript/mal_parser.js) — Парсинг списков MyAnimeList.

27
package-lock.json generated Normal file
View File

@ -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"
}
}
}
}

6
package.json Normal file
View File

@ -0,0 +1,6 @@
{
"private": true,
"devDependencies": {
"prettier": "^2.8.8"
}
}