Skip to content

Commit 822de84

Browse files
Merge pull request #28 from yuran1811/fix-fireship-vip
fix: 🐛 fix fireship_vip script
2 parents b15dea9 + a719d9b commit 822de84

File tree

1 file changed

+51
-28
lines changed

1 file changed

+51
-28
lines changed

scripts/fireship_vip.js

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
export default {
2-
icon: "https://fireship.io/img/favicon.png",
2+
icon: 'https://fireship.io/img/favicon.png',
33
name: {
4-
en: "Fireship - PRO unlocked",
5-
vi: "Fireship - Mở khoá PRO",
4+
en: 'Fireship - PRO unlocked',
5+
vi: 'Fireship - Mở khoá PRO',
66
},
77
description: {
8-
en: "Unlock all Fireship PRO courses/lessons (saved $399 USD)",
9-
vi: "Mở khoá tất cả khoá học/bài giảng PRO trên Fireship (tiết kiệm $399 USD)",
8+
en: 'Unlock all Fireship PRO courses/lessons (saved $399 USD)',
9+
vi: 'Mở khoá tất cả khoá học/bài giảng PRO trên Fireship (tiết kiệm $399 USD)',
1010
},
11-
infoLink: "https://fireship.io/",
11+
infoLink: 'https://fireship.io/',
1212

13-
whiteList: ["https://fireship.io/*"],
13+
whiteList: ['https://fireship.io/*'],
1414

15-
contentScript: {
15+
pageScript: {
1616
onDocumentIdle: () => {
1717
// ==UserScript==
1818
// @name Freeship
1919
// @namespace lemons
20-
// @version 1.7
20+
// @version 1.8
2121
// @description Unlock all Fireship PRO courses/lessons.
2222
// @author lemons
2323
// @match https://fireship.io/*
@@ -27,31 +27,54 @@ export default {
2727
// @updateURL https://update.greasyfork.org/scripts/455330/Freeship.meta.js
2828
// ==/UserScript==
2929

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

34-
if (document.querySelector("if-access [slot=\"granted\"]")) { // replace HOW TO ENROLL to YOU HAVE ACCESS
35-
document.querySelector("if-access [slot=\"denied\"]").remove()
36-
document.querySelector("if-access [slot=\"granted\"]").setAttribute("slot", "denied")
32+
const unlock = async () => {
33+
// set all elements with the attribute free set to "" to true
34+
document.querySelectorAll('[free=""]').forEach((el) => el.setAttribute('free', true));
35+
36+
if (document.querySelector('if-access [slot="granted"]')) {
37+
// replace HOW TO ENROLL to YOU HAVE ACCESS
38+
document.querySelector('if-access [slot="denied"]').remove();
39+
document.querySelector('if-access [slot="granted"]').setAttribute('slot', 'denied');
3740
}
3841

39-
if (document.querySelector("video-player")?.shadowRoot?.querySelector(".vid")?.innerHTML) return; // return if no video player
40-
const vimeoId = Number(atob(document.querySelector("global-data").vimeo)); // get id for vimeo video
41-
const youtubeId = atob(document.querySelector("global-data").youtube); // get id for vimeo video
42+
// return if no video player
43+
if (document.querySelector('video-player')?.shadowRoot?.querySelector('.vid')?.innerHTML) return;
44+
45+
// get id for vimeo video
46+
const vimeoId = Number(atob(document.querySelector('global-data').vimeo || btoa('')));
4247

43-
if (youtubeId) { // if there is an id,
44-
document.querySelector("video-player").setAttribute("free", true) // set free to true
45-
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
46-
return;
48+
// get id for vimeo video
49+
const youtubeId = atob(document.querySelector('global-data').youtube || btoa(''));
50+
51+
if (youtubeId) {
52+
// if there is an id,
53+
document.querySelector('video-player').setAttribute('free', true); // set free to true
54+
document
55+
.querySelector('video-player')
56+
.shadowRoot.querySelector(
57+
'.vid'
58+
).innerHTML = `<iframe src="https://youtube.com/embed/${youtubeId}" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen="" title="${
59+
location.pathname.split('/')[3]
60+
}" width="426" height="240" frameborder="0"></iframe>`; // set video
61+
return;
4762
}
48-
if (vimeoId) { // if there is an id,
49-
document.querySelector("video-player").setAttribute("free", true) // set free to true
50-
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
51-
document.querySelector("video-player").shadowRoot.querySelector(".vid").innerHTML = html // set video
52-
return;
63+
if (vimeoId) {
64+
// if there is an id,
65+
document.querySelector('video-player').setAttribute('free', true); // set free to true
66+
const html = (
67+
await fetch(
68+
`https://vimeo.com/api/oembed.json?url=https%3A%2F%2Fvimeo.com%2F${vimeoId}&id=${vimeoId}`
69+
).then((r) => r.json())
70+
).html;
71+
document.querySelector('video-player').shadowRoot.querySelector('.vid').innerHTML = html; // set video
72+
return;
5373
}
54-
}, 500)
74+
};
75+
76+
window.onload = unlock();
77+
window.addEventListener('flamethrower:router:end', unlock);
5578
},
5679
},
5780
};

0 commit comments

Comments
 (0)