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: 🐛 fix fireship_vip script #28

Merged
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
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);
},
},
};