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

FIx Toonkor : get domain from telegram #6334

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions src/web/mjs/connectors/Toonkor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,32 @@ export default class Toonkor extends GnuBoard5BootstrapBasic2 {
super.id = 'toonkor';
super.label = 'Toonkor';
this.tags = ['webtoon', 'korean'];
this.url = 'https://tkor.zone';
this.url = 'https://t.me/s/new_toonkor';
this.hostRegexp = /https?:\/\/(?:toonkor|tkor)([\d]+)?\.[a-z]+/;
}

canHandleURI(uri) {
return /https?:\/\/(?:toonkor|tkor)\.[a-z]+/.test(uri.origin);
return this.hostRegexp.test(uri.origin);
}

async _initializeConnector() {
let uri = new URL(await this._twitter.getProfileURL('1202224761771741184') || this.url);
let request = new Request(uri.href, this.requestOptions);
this.url = await Engine.Request.fetchUI(request, `window.location.origin`);
const script = `
new Promise((resolve, reject) => {
setTimeout(() => {
//fetch telegram messages with links, reverse it because last one is more recent one, and get the first matching our regex
const tkLinks = [...document.querySelectorAll('section.tgme_channel_history div.tgme_widget_message_wrap .tgme_widget_message_text a ')].reverse();
for (const link of tkLinks) {
if ( ${this.hostRegexp}.test(link.href)) {
MikeZeDev marked this conversation as resolved.
Show resolved Hide resolved
resolve(link.href);
break;
}
}
},1500);
});
`;
const uri = new URL(this.url);
const request = new Request(uri.href, this.requestOptions);
this.url = await Engine.Request.fetchUI(request, script);
console.log(`Assigned URL '${this.url}' to ${this.label}`);
}
}
}
Loading