Skip to content

Commit

Permalink
fix: better url wildcard + episodes player
Browse files Browse the repository at this point in the history
  • Loading branch information
Dastan21 committed Feb 23, 2023
1 parent d2ce64f commit 8e3b91b
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 21 deletions.
4 changes: 4 additions & 0 deletions src/assets/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,10 @@ bva-button-icon:active {
aspect-ratio: 16 / 9;
}

#chapter-video-captcha-validator > :not(.g-recaptcha) {
display: none;
}

.bva-episode-video p {
padding: 0 !important;
margin: 0 !important;
Expand Down
2 changes: 1 addition & 1 deletion src/common/api.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BASE_URL, getCurrentSection, NEED_REFRESH, onTrigger } from './utils'
import { parseHTML, parseFormData } from './parser'

export const API_URL = `${BASE_URL}wp-admin/admin-ajax.php`
export const API_URL = `${BASE_URL}/wp-admin/admin-ajax.php`
export const API_OPTIONS = 'current_page_id=15&qtranslate_lang=0&filters_changed=0&filters_initial=1&asp_gen%5B%5D=title&asp_gen%5B%5D=content&asp_gen%5B%5D=excerpt&customset%5B%5D=wp-manga&aspf%5Bvf__1%5D=vf'

window.cache = new Map()
Expand Down
4 changes: 2 additions & 2 deletions src/common/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ const menuTab = {
title: 'Découvrir un animé'
},
action: () => {
request(`${BASE_URL}liste-danimes/`).then((res) => {
request(`${BASE_URL}/liste-danimes/`).then((res) => {
const totalPages = res.body.querySelector('.wp-pagenavi .last').getAttribute('href').match(/(\d*)\/$/)?.[1]
const page = Math.floor((Math.random() * totalPages)) + 1
request(`${BASE_URL}liste-danimes/page/${page}/`, { abortPrevious: true }).then((res) => {
request(`${BASE_URL}/liste-danimes/page/${page}/`, { abortPrevious: true }).then((res) => {
const animes = collectionToArray(res.body.querySelectorAll('.page-listing-item .item-thumb a'))
const randomAnimeUrl = animes[~~(Math.random() * animes.length)].getAttribute('href')
changePage(randomAnimeUrl)
Expand Down
6 changes: 3 additions & 3 deletions src/common/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function parseAnime (root = window.body) {
if (key === 'genre(s)' || key === 'genres') {
anime.genres = value.toLowerCase().split(', ').map((genre) => ({
label: capitalize(translateGenre(genre)),
url: `${BASE_URL}anime-genre/${encodeURI(genre)}`
url: `${BASE_URL}/anime-genre/${encodeURI(genre)}`
}))
}
})
Expand All @@ -90,11 +90,11 @@ export function parseEpisode (root = window.body) {
const $nav = root.querySelector('#manga-reading-nav-head')
const title = root.querySelector('.breadcrumb > li.active').textContent.trim()
return {
id: $ids.getAttribute('data-chapter'),
id: $ids?.getAttribute('data-chapter') ?? root.querySelector('[name="wp_manga_chapter_id"]')?.getAttribute('value'),
title,
hosts: collectionToArray($nav.querySelectorAll('.host-select > option')).map((o) => o.value.replace('LECTEUR ', '')),
anime: {
id: $ids.getAttribute('data-post'),
id: $ids?.getAttribute('data-post') ?? $nav.getAttribute('data-id'),
title: title.split(' - ')[0]
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as storage from './storage'

export const BASE_URL = 'https://voiranime.com/'
export const BASE_URL = location.origin

export const NEED_REFRESH = ['episode']

Expand Down
26 changes: 13 additions & 13 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Better VoirAnime",
"version": "0.0.5",
"version": "0.0.6",
"manifest_version": 3,
"description": "A powerful UI/UX changer for 'voiranime.com'",
"icons": {
Expand All @@ -16,29 +16,29 @@
"style.css"
],
"matches": [
"*://voiranime.com/*"
"*://*.voiranime.com/*"
],
"exclude_matches": [
"*://voiranime.com/wp-content/*",
"*://voiranime.com/wp-admin/*",
"*://voiranime.com/wp-login*",
"*://voiranime.com/feed/*",
"*://voiranime.com/user-settings*"
"*://*.voiranime.com/wp-content/*",
"*://*.voiranime.com/wp-admin/*",
"*://*.voiranime.com/wp-login*",
"*://*.voiranime.com/feed/*",
"*://*.voiranime.com/user-settings*"
]
}],
"web_accessible_resources": [{
"resources": [
"public/**/*.*"
],
"matches": [
"*://voiranime.com/*"
"*://*.voiranime.com/*"
],
"exclude_matches": [
"*://voiranime.com/wp-content/*",
"*://voiranime.com/wp-admin/*",
"*://voiranime.com/wp-login*",
"*://voiranime.com/feed/*",
"*://voiranime.com/user-settings*"
"*://*.voiranime.com/wp-content/*",
"*://*.voiranime.com/wp-admin/*",
"*://*.voiranime.com/wp-login*",
"*://*.voiranime.com/feed/*",
"*://*.voiranime.com/user-settings*"
]
}],
"permissions": [
Expand Down
1 change: 0 additions & 1 deletion src/pages/episode.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ export function buildEpisodePage () {

if (checkingCaptcha) return
checkingCaptcha = true
document.getElementById('wp-manga-current-chap')?.remove()
setEpisodeClass()
// auto valid video
observe('#chapter-video-captcha-validator .btn[type="submit"]', ($btn) => {
Expand Down

0 comments on commit 8e3b91b

Please sign in to comment.