Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CoroCoro connector #7472

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Add CoroCoro connector #7472

wants to merge 6 commits into from

Conversation

viliml
Copy link
Contributor

@viliml viliml commented Oct 10, 2024

No description provided.

Copy link
Contributor

@MikeZeDev MikeZeDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work but

  • Dont assume the script you want is the nth script in all the page scripts. Perform checks on the script content instead.

  • I dont like those eval at all. If you want to use eval perhaps you should use them in browser context i.e injecting a script using Engine.Request.fetchUI. Perhaps is event easier this way, if you are able to parse next_f array idk.

src/web/mjs/connectors/CoroCoro.mjs Outdated Show resolved Hide resolved
src/web/mjs/connectors/CoroCoro.mjs Outdated Show resolved Hide resolved
src/web/mjs/connectors/CoroCoro.mjs Outdated Show resolved Hide resolved
src/web/mjs/connectors/CoroCoro.mjs Outdated Show resolved Hide resolved
src/web/mjs/connectors/CoroCoro.mjs Outdated Show resolved Hide resolved
src/web/mjs/connectors/CoroCoro.mjs Outdated Show resolved Hide resolved
src/web/mjs/connectors/CoroCoro.mjs Outdated Show resolved Hide resolved
src/web/mjs/connectors/CoroCoro.mjs Outdated Show resolved Hide resolved
src/web/mjs/connectors/CoroCoro.mjs Outdated Show resolved Hide resolved
src/web/mjs/connectors/CoroCoro.mjs Outdated Show resolved Hide resolved
@viliml viliml requested a review from MikeZeDev October 10, 2024 20:09
async _getMangas() {
/** @type {HTMLScriptElement[]} */
const scripts = await this.fetchDOM(this.url + '/rensai', 'script');
for (const scriptElem of scripts.reverse()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to loop by yourself if you can identify the script by content

const scripts = [...document.querySelectorAll('script')];
const script = scripts.find(script=> script.innerText.indexOf('totalChapterLikes') > 0)?.innerText;
const json = JSON.parse(script.substring(22, script.length - 2));
const data = JSON.parse(json.substring(json.indexOf(':') + 1))[3]['children'][3]['weekdays'];

src/web/mjs/connectors/CoroCoro.mjs Outdated Show resolved Hide resolved
src/web/mjs/connectors/CoroCoro.mjs Outdated Show resolved Hide resolved
const script = scriptElem.innerText;
try {
/** @type {string} */
const json = JSON.parse(script.substring(22, script.length - 2));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, since JSON parsing first steps are the same perhaps we should make a function?

function findAndParseJSON(scripts, textToFind) {
  const script = scripts.find(script=> script.innerText.indexOf(textToFind) > 0)?.innerText;
  const json = JSON.parse(script.substring(22, script.length - 2));
  return JSON.parse(json.substring(json.indexOf(':') + 1))
}

const scripts = [...document.querySelectorAll('script')];
const data = findAndParseJSON( scripts, 'weekdays');

@viliml
Copy link
Contributor Author

viliml commented Oct 12, 2024

The "allow edits by maintainers" checkbox is checked, since you're already writing full snippets of fixed code in your comments you might as well commit them.

@MikeZeDev
Copy link
Contributor

I have no time to spare and no intention to add such complex website to Hakuneko anymore. Its better for the team and for everyone to spend time on Haruneko where this website was added and working until its last update.

@ronny1982
Copy link
Contributor

Suggestion to close PR after Thursday, 2 January 2025 (12 weeks) if not approved by a reviewer.

@viliml viliml requested a review from MikeZeDev December 11, 2024 23:28
@MikeZeDev
Copy link
Contributor

Ooooh, they use protobuff now? awesome, gotta review that asap <3

Copy link
Contributor

@MikeZeDev MikeZeDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work with the prototypes.
Some things still must be changed tho.

}

/**
* @param {URL} uri
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment should be removed as its content can easily be inferred from the code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same everywhere else

@MikeZeDev
Copy link
Contributor

Hey, they just added a new endpoint for rensai ! you can get rid of all those JSON parsing !

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants