Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
Bump 1.3.0a
Browse files Browse the repository at this point in the history
  • Loading branch information
Rgern100 committed Aug 13, 2022
1 parent 088a618 commit 476c1d1
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 40 deletions.
25 changes: 15 additions & 10 deletions Crunchyroll_Premium/background.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions Crunchyroll_Premium/blockevidon.js

This file was deleted.

17 changes: 12 additions & 5 deletions Crunchyroll_Premium/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ function importBetaPlayer(ready = false) {
if (query('.video-player') && lastWatchedPlayer)
lastWatchedPlayer.parentNode.removeChild(lastWatchedPlayer);

var titleLink = query('.show-title-link')
if (titleLink) titleLink.style.zIndex = "2";

console.log("[CR Beta] Removendo player da Crunchyroll...");
remove('.video-player-placeholder', 'Video Placeholder');
remove('.video-player', 'Video Player', true);
Expand All @@ -93,10 +96,10 @@ function importBetaPlayer(ready = false) {
var external_lang = preservedState.localization.locale.toLowerCase()
var ep_lang = preservedState.localization.locale.replace('-', '')
var ep_id = preservedState.watch.id
var ep = preservedState.content.byId[ep_id]
var ep = preservedState.content.media.byId[ep_id]
if (!ep) { window.location.reload(); return; }
var series_slug = ep.episode_metadata.series_slug_title
var external_id = ep.external_id.substr(4)
var series_slug = ep.parentSlug
var external_id = getExternalId(ep.id).substr(4)
var old_url = `https://www.crunchyroll.com/${external_lang}/${series_slug}/episode-${external_id}`
var up_next = document.querySelector('[data-t="next-episode"] > a')
var playback = ep.playback
Expand Down Expand Up @@ -135,7 +138,7 @@ function addPlayer(element, playerInfo, beta = false) {
playerInfo['up_next_cooldown'] = items.cooldown === undefined ? 5 : items.cooldown;
playerInfo['up_next_enable'] = items.aseguir === undefined ? true : items.aseguir;
playerInfo['force_mp4'] = items.forcemp4 === undefined ? false : items.forcemp4;
playerInfo['version'] = '1.2.2';
playerInfo['version'] = '1.3.0a';
playerInfo['noproxy'] = true;
playerInfo['beta'] = beta;
ifrm.contentWindow.postMessage(playerInfo, "*");
Expand Down Expand Up @@ -208,7 +211,11 @@ function fetch(url) {
})
}

function getExternalId(id) {
return JSON.parse(localStorage.getItem('externalIds'))[id];
}

var s = document.createElement('script');
s.src = browser.runtime.getURL('blockevidon.js');
s.src = browser.runtime.getURL('interceptor.js');
s.onload = function () { this.remove(); };
(document.head || document.documentElement).appendChild(s);
68 changes: 68 additions & 0 deletions Crunchyroll_Premium/interceptor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
window.evidon_dg = {}

Object.defineProperty(window.evidon_dg, "evidonCriticalDomains", {
get: function () { return ['wvc-x-callback:']; },
});
Object.defineProperty(window.evidon_dg, "productNames", {
get: function () { return {}; },
});
Object.defineProperty(window.evidon_dg, "loadedProducts", {
get: function () { return []; },
});
Object.defineProperty(window.evidon_dg, "productIds", {
get: function () { return []; },
});

console.log("[CR XHR] Configurando interceptor...")
var rawOpen = XMLHttpRequest.prototype.open;

XMLHttpRequest.prototype.open = function () {
if (!this._hooked) {
this._hooked = true;
setupHook(this);
}
rawOpen.apply(this, arguments);
}

function setupHook(xhr) {
let toggle = false;
function getter() {
delete xhr.responseText;
var ret = xhr.responseText;
try {
if (toggle = !toggle) handleIntercept(JSON.parse(ret));
} catch (e) { }
setup();
return ret;
}

function setup() {
Object.defineProperty(xhr, 'responseText', {
get: getter,
configurable: true
});
}
setup();
}

const verbose = false;
// Intercepta response das requests (network)
function handleIntercept(jsonResponse) {
if (verbose) console.log("[CR XHR]", jsonResponse);

// Salva IDs externos dos panels no localStorage
if (jsonResponse.items) jsonResponse.items.forEach(item => {
if (item.id && item.external_id) {
console.log("[CR XHR] Panel found:", item);
storeExternalId(item.id, item.external_id)
}
})
}

function storeExternalId(id, external_id) {
let externalIds = localStorage.getItem('externalIds');
if (externalIds) externalIds = JSON.parse(externalIds)
else externalIds = {};
externalIds[id] = external_id;
localStorage.setItem('externalIds', JSON.stringify(externalIds));
}
8 changes: 4 additions & 4 deletions Crunchyroll_Premium/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Crunchyroll iFrame Player",
"version": "1.2.2",
"version": "1.3.0a",
"description": "Permite ver todos os vídeos do crunchyroll gratuitamente.",
"author": "itallolegal",
"icons": {
Expand All @@ -16,9 +16,9 @@
"id": "asdhawuodhcauowchauohwoaduji9hfjdaopi@gmail.com"
}
},
"permissions": ["webRequest", "webRequestBlocking", "storage", "*://pl.crunchyroll.com/*", "*://localhost/*", "*://www.crunchyroll.com/*", "*://rgern100.github.io/*", "*://*.vrv.co/*"],
"permissions": ["webRequest", "webRequestBlocking", "storage", "*://*.crunchyroll.com/*", "*://localhost/*", "*://rgern100.github.io/*", "*://*.vrv.co/*"],
"content_scripts": [{
"matches": ["https://*.crunchyroll.com/*"],
"matches": ["*://*.crunchyroll.com/*"],
"css": ["content.css"],
"js": ["content.js"],
"run_at": "document_start"
Expand All @@ -28,7 +28,7 @@
"scripts": ["background.js"]
},
"web_accessible_resources": [
"blockevidon.js"
"interceptor.js"
],
"manifest_version": 2
}
7 changes: 4 additions & 3 deletions assets/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ window.addEventListener("message", async e => {
playerInstance.addButton(...webvideocasterBtn);
else
playerInstance.addButton(...downloadBtn);
if (!tampermonkey && version !== "1.2.2")
if (!tampermonkey && version !== "1.3.0a")
playerInstance.addButton(...updateBtn);

// Definir URL e Tamanho na lista de download
Expand Down Expand Up @@ -352,8 +352,9 @@ window.addEventListener("message", async e => {
return JSON.parse(video_config_media)
else if (old_url) {
const localelessUrl = old_url.split('/').length == 6 ? old_url.replace(/\.com\/[^/]*?\//, '.com/') : old_url
console.log("[CR Beta] URL universal:", localelessUrl)
const media_content = await getVilosMedia(localelessUrl + '?skip_wall=1')
const normalizedUrl = localelessUrl.replaceAll("--", "-")
console.log("[CR Beta] URL universal:", normalizedUrl)
const media_content = await getVilosMedia(normalizedUrl + '?skip_wall=1')
return JSON.parse(media_content)
}
else return {}
Expand Down
6 changes: 2 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,12 @@
<button class="close-modal">×</button>
<div class="download-item">
<span class="partdditem quality not-copyable">Changelog</span>
<span class="partdditem size not-copyable">v1.2.2</span>
<span class="partdditem size not-copyable">v1.3.0a</span>
</div>
<div class="download-item">
<span id="changelog" class="partdditem quality not-copyable" style="font-family: 'SFProDisplay-Regular';">
<strong>Update available:</strong><br/>
- Fix <strong>Crunchyroll Beta</strong> compatibility<br/>
- Fix WebVideoCaster button
- Fix popup default values
- Fix <strong>Crunchyroll Beta</strong><br/>
</span>
</div>
<div class="download-item">
Expand Down

0 comments on commit 476c1d1

Please sign in to comment.