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

New Page AnimesOnline #2392

Merged
merged 4 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
106 changes: 106 additions & 0 deletions src/pages/AnimesOnline/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { pageInterface } from '../pageInterface';

let originalSrc;
const changeSrc = (currentPlayer, currentTries = 0) => {
const tempSrc = $(`#tab-${currentPlayer} video`).attr('src');

if (tempSrc === undefined) {
if (currentTries >= 100) {
alert('MAL-SYNC: Cant find target src video, please refresh the page and try again!');
Copy link
Member

Choose a reason for hiding this comment

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

Alerts are a bit hard. Please use

utils.flashm(`MAL-SYNC: Cant find target src video, please refresh the page and try again!`, {
    error: true,
    type: 'error',
  });

return;
}

setTimeout(() => {
currentTries++;
changeSrc(currentPlayer, currentTries);
}, 50);
return;
}

$('.player.current').removeClass('current');
$('#tab-1').addClass('current');

$($('video')[0]).attr('src', currentPlayer === 1 ? originalSrc : tempSrc ?? originalSrc);
};

export const AnimesOnline: pageInterface = {
name: 'Animes Online',
domain: 'animesonline.in',
Copy link
Member

Choose a reason for hiding this comment

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

Please use https://animesonline.in

languages: ['Portuguese'],
type: 'anime',
isSyncPage(url) {
return utils.urlPart(url, 3).startsWith('video');
},
isOverviewPage(url) {
return ['anime', 'animes-dublado'].includes(utils.urlPart(url, 3));
},
sync: {
getTitle(url) {
return j.$(j.$('.breadcrumb li')[2]).text().replace('- Dublado', '').trim();
},
getIdentifier(url) {
return j.$(j.$('.breadcrumb li')[2]).text().trim().replace('- Dublado', '');
},
Copy link
Member

Choose a reason for hiding this comment

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

duplicated code. One could just call return AnimesOnline.sync.getTitle(url);

getOverviewUrl(url) {
return j.$(j.$('.breadcrumb li')[2]).find('a').attr('href') ?? '';
},
getEpisode(url) {
return Number(j.$(j.$('.breadcrumb li')[3]).text().split('ep')[1].trim());
},
nextEpUrl(url) {
return j.$(j.$('.playerbox .controls a')[2]).attr('href');
},
},
overview: {
getTitle(url) {
return j.$(j.$('.breadcrumb li')[2]).text().replace('- Dublado', '').trim();
},
getIdentifier(url) {
return j.$(j.$('.breadcrumb li')[2]).text().replace('- Dublado', '').trim();
},
Copy link
Member

Choose a reason for hiding this comment

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

More duplicated code. You can just call the functions of the sync section

uiSelector(selector) {
j.$('.banner-infos > .info:last-child').after(
j.html(`<div title="MalSync">${j.html(selector)}</div>`),
);
},
list: {
offsetHandler: false,
elementsSelector() {
return j.$('.episode-card');
},
elementUrl(selector) {
return utils.absoluteLink(
j.$(selector.find('a').first()).attr('href'),
AnimesOnline.domain,
);
},
elementEp(selector) {
return Number(selector.find('.card-title span').text().split('EP')[1].trim());
},
},
},
init(page) {
j.$(document).ready(function () {
api.storage.addStyle(
require('!to-string-loader!css-loader!less-loader!./style.less').toString(),
);

originalSrc = $($('.player video')[0]).attr('src');

page.handlePage();

$('.player-option a').on('click', function () {
const currentPlayer = Number($(this).parent().data('tab').split('-')[1]);

// required to make a first click so it thinks that the player is setup and playing
$('video')[0].click();
// @ts-ignore
$('video')[0].pause();

setTimeout(() => {
changeSrc(currentPlayer);
}, 500);
});
});
},
};
7 changes: 7 additions & 0 deletions src/pages/AnimesOnline/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"search": "https://www.animesonline.in/busca?s={searchtermPlus}",
"urls": {
"match": ["*://*.animesonline.in/*"]
}
}

52 changes: 52 additions & 0 deletions src/pages/AnimesOnline/style.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@import './../pages';

#malp {
margin-top: 10px;
}

#MalData {
flex-direction: column;
}

#malStatus,
#malTotal,
#malEpisodes,
#malUserRating,
#malRating,
#malVolumes,
#malTotalVol,
#malTotalCha,
#AddMal {
color: #fff;
font-weight: 400;
}

// Fix spacing
.MalLogin:last-child span::after {
content: ' ';
}

article.episode-card.mal-sync-active::before {
content: 'MAL-SYNC';
display: inline-block;
position: absolute;
right: 0;
z-index: 1;
background: #002966;
padding: 5px 10px;
border-radius: 0 3px;
}

.malp-group {
display: flex !important;
margin-top: 4px;
}

.malp-group-label {
padding-top: 0 !important;
color: #2ecc71;
}

.open-info-popup.floatbutton > i {
filter: invert(1);
}
31 changes: 31 additions & 0 deletions src/pages/AnimesOnline/tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"title": "AnimesOnline",
"url": "https://www.animesonline.in/",
"testCases": [
{
"url": "https://www.animesonline.in/anime/398a5cebfadb2606fbf802b42aad57755b4eae55",
"expected": {
"sync": false,
"title": "One Piece",
"identifier": "One Piece",
"uiSelector": true,
"epList": {
"1": "https://www.animesonline.in/video/346066",
"10": "https://www.animesonline.in/video/346030",
"17": "https://www.animesonline.in/video/346054"
}
}
},
{
"url": "https://www.animesonline.in/video/346066",
"expected": {
"sync": true,
"title": "One Piece",
"identifier": "One Piece",
"episode": 1,
"overviewUrl": "https://www.animesonline.in/anime/398a5cebfadb2606fbf802b42aad57755b4eae55",
"nextEpUrl": "https://www.animesonline.in/video/346078"
}
}
]
}
2 changes: 2 additions & 0 deletions src/pages/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ import { WitAnime } from './WitAnime/main';
import { Suwayomi } from './Suwayomi/main';
import { ManhuaUS } from './ManhuaUS/main';
import { Taiyo } from './Taiyo/main';
import { AnimesOnline } from './AnimesOnline/main';

export const pages = {
nineAnime,
Expand Down Expand Up @@ -262,4 +263,5 @@ export const pages = {
Suwayomi,
ManhuaUS,
Taiyo,
AnimesOnline,
};
Loading