Skip to content

Commit

Permalink
Merge pull request #28 from yuran1811/fix-fireship-vip
Browse files Browse the repository at this point in the history
fix: 🐛 fix fireship_vip script
  • Loading branch information
HoangTran0410 authored Jul 6, 2024
2 parents b15dea9 + a719d9b commit 822de84
Showing 1 changed file with 51 additions and 28 deletions.
79 changes: 51 additions & 28 deletions scripts/fireship_vip.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
export default {
icon: "https://fireship.io/img/favicon.png",
icon: 'https://fireship.io/img/favicon.png',
name: {
en: "Fireship - PRO unlocked",
vi: "Fireship - Mở khoá PRO",
en: 'Fireship - PRO unlocked',
vi: 'Fireship - Mở khoá PRO',
},
description: {
en: "Unlock all Fireship PRO courses/lessons (saved $399 USD)",
vi: "Mở khoá tất cả khoá học/bài giảng PRO trên Fireship (tiết kiệm $399 USD)",
en: 'Unlock all Fireship PRO courses/lessons (saved $399 USD)',
vi: 'Mở khoá tất cả khoá học/bài giảng PRO trên Fireship (tiết kiệm $399 USD)',
},
infoLink: "https://fireship.io/",
infoLink: 'https://fireship.io/',

whiteList: ["https://fireship.io/*"],
whiteList: ['https://fireship.io/*'],

contentScript: {
pageScript: {
onDocumentIdle: () => {
// ==UserScript==
// @name Freeship
// @namespace lemons
// @version 1.7
// @version 1.8
// @description Unlock all Fireship PRO courses/lessons.
// @author lemons
// @match https://fireship.io/*
Expand All @@ -27,31 +27,54 @@ export default {
// @updateURL https://update.greasyfork.org/scripts/455330/Freeship.meta.js
// ==/UserScript==

// prettier-ignore
setInterval(async () => {
document.querySelectorAll("[free=\"\"]").forEach(el => el.setAttribute("free", true)) // set all elements with the attribute free set to "" to true
console.log('use fireship_vip.js');

if (document.querySelector("if-access [slot=\"granted\"]")) { // replace HOW TO ENROLL to YOU HAVE ACCESS
document.querySelector("if-access [slot=\"denied\"]").remove()
document.querySelector("if-access [slot=\"granted\"]").setAttribute("slot", "denied")
const unlock = async () => {
// set all elements with the attribute free set to "" to true
document.querySelectorAll('[free=""]').forEach((el) => el.setAttribute('free', true));

if (document.querySelector('if-access [slot="granted"]')) {
// replace HOW TO ENROLL to YOU HAVE ACCESS
document.querySelector('if-access [slot="denied"]').remove();
document.querySelector('if-access [slot="granted"]').setAttribute('slot', 'denied');
}

if (document.querySelector("video-player")?.shadowRoot?.querySelector(".vid")?.innerHTML) return; // return if no video player
const vimeoId = Number(atob(document.querySelector("global-data").vimeo)); // get id for vimeo video
const youtubeId = atob(document.querySelector("global-data").youtube); // get id for vimeo video
// return if no video player
if (document.querySelector('video-player')?.shadowRoot?.querySelector('.vid')?.innerHTML) return;

// get id for vimeo video
const vimeoId = Number(atob(document.querySelector('global-data').vimeo || btoa('')));

if (youtubeId) { // if there is an id,
document.querySelector("video-player").setAttribute("free", true) // set free to true
document.querySelector("video-player").shadowRoot.querySelector(".vid").innerHTML = `<iframe src="https://youtube.com/embed/${youtubeId}" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen="" title="${location.pathname.split("/")[3]}" width="426" height="240" frameborder="0"></iframe>` // set video
return;
// get id for vimeo video
const youtubeId = atob(document.querySelector('global-data').youtube || btoa(''));

if (youtubeId) {
// if there is an id,
document.querySelector('video-player').setAttribute('free', true); // set free to true
document
.querySelector('video-player')
.shadowRoot.querySelector(
'.vid'
).innerHTML = `<iframe src="https://youtube.com/embed/${youtubeId}" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen="" title="${
location.pathname.split('/')[3]
}" width="426" height="240" frameborder="0"></iframe>`; // set video
return;
}
if (vimeoId) { // if there is an id,
document.querySelector("video-player").setAttribute("free", true) // set free to true
const html = (await fetch(`https://vimeo.com/api/oembed.json?url=https%3A%2F%2Fvimeo.com%2F${vimeoId}&id=${vimeoId}`).then(r=>r.json())).html
document.querySelector("video-player").shadowRoot.querySelector(".vid").innerHTML = html // set video
return;
if (vimeoId) {
// if there is an id,
document.querySelector('video-player').setAttribute('free', true); // set free to true
const html = (
await fetch(
`https://vimeo.com/api/oembed.json?url=https%3A%2F%2Fvimeo.com%2F${vimeoId}&id=${vimeoId}`
).then((r) => r.json())
).html;
document.querySelector('video-player').shadowRoot.querySelector('.vid').innerHTML = html; // set video
return;
}
}, 500)
};

window.onload = unlock();
window.addEventListener('flamethrower:router:end', unlock);
},
},
};

0 comments on commit 822de84

Please sign in to comment.