Skip to content
This repository has been archived by the owner on Feb 10, 2024. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
honzawashere authored Sep 8, 2022
1 parent f0a9d61 commit 9685171
Show file tree
Hide file tree
Showing 10 changed files with 8,336 additions and 0 deletions.
33 changes: 33 additions & 0 deletions ads.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const { ElectronBlocker } = require("@cliqz/adblocker-electron")
const fetch = require("node-fetch")

const path = require("path")
const { promises } = require("fs")

const urls = [
"https://raw.githubusercontent.com/kbinani/adblock-youtube-ads/master/signed.txt",
"https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/filters.txt",
"https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/filters-2021.txt",
"https://secure.fanboy.co.nz/fanboy-annoyance_ubo.txt",
]

this.blocker = (
session,
cache = true,
additionalBlockLists = [],
disableDefaultLists = false
) => {
const cachingOptions = { path: path.resolve(__dirname, "ad-blocker-engine.bin"), read: promises.readFile, write: promises.writeFile }

ElectronBlocker.fromLists(
fetch,
urls,
{
loadNetworkFilters: session,
},
cachingOptions
)
.then((blocker) => blocker.enableBlockingInSession(session))
.catch((err) => console.log("Error loading adBlocker engine", err));
console.log("blocking ads")
};
248 changes: 248 additions & 0 deletions discord.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
let rpcClient = null
const { dev } = require("electron-is")

module.exports.connect = () => {
const rpc = require("discord-rpc")
const client = new rpc.Client({ transport: 'ipc' })

client.login({ clientId: "922907049170464809" })

client.on("ready", () => {
rpcClient = client
return
})

client.on("disconnected", () => {
rpcClient = null
return
})
}

module.exports.close = () => {
if (rpcClient == null) return
if (rpcClient !== null) {
rpcClient.setActivity(null)
rpcClient = null
}
}

module.exports.setActivity = async (title, author, photo, progress, fullLength, playbackState, finalDetails, videoId) => {
if (rpcClient == null) {
if (rpcClient !== null) return
this.connect()
}

const state = {
true: "Playing",
false: "Paused",
badge: "YouTube Music",
none: "no"
}

const photos = {
badge: "badge",
true: "play",
false: "pause",
none: "no"
}

if (photo == "largebadge") {
if (playbackState == "badge") {
playbackState = "none"
}
}

const db = require("simpl.db")

let videoLink
let player = new db.Database({ dataFile: "./json/player.json" })

if (player.get("videoId") !== "") {
if (videoId = true) {
videoLink = "https://music.youtube.com/watch?v=" + player.get("videoId")
}
}

const startTime = Date.now() - progress * 1000
const endTime = startTime + fullLength * 1000

if (playbackState == false) {
if (videoLink) {
if (author == "") {
rpcClient.setActivity(
{
smallImageText: state[playbackState],
smallImageKey: photos[playbackState],
largeImageText: finalDetails,
type: 4,
details: title,
largeImageKey: photo,
buttons: [
{
url: videoLink,
label: "Play Video"
},
{
url: "https://github.com/iwillfightfordream/youtube-music-discord-rpc",
label: "Download from GitHub"
}
]
}
)
return
}
rpcClient.setActivity(
{
smallImageText: state[playbackState],
smallImageKey: photos[playbackState],
largeImageText: finalDetails,
type: 4,
details: title,
state: author,
largeImageKey: photo,
buttons: [
{
url: videoLink,
label: "Play Video"
},
{
url: "https://github.com/iwillfightfordream/youtube-music-discord-rpc",
label: "Download from GitHub"
}
]
}
)
return
}
if (author == "") {
rpcClient.setActivity(
{
smallImageText: state[playbackState],
smallImageKey: photos[playbackState],
largeImageText: finalDetails,
type: 4,
details: title,
largeImageKey: photo,
}
)
return
}
rpcClient.setActivity(
{
smallImageText: state[playbackState],
smallImageKey: photos[playbackState],
largeImageText: finalDetails,
type: 4,
details: title,
state: author,
largeImageKey: photo
}
)
return
}

// Playing
if (videoLink) {
if (author == "") {
rpcClient.setActivity(
{
smallImageText: state[playbackState],
smallImageKey: photos[playbackState],
largeImageText: finalDetails,
type: 4,
details: title,
startTimestamp: startTime,
endTimestamp: endTime,
largeImageKey: photo,
buttons: [
{
url: videoLink,
label: "Play Video"
},
{
url: "https://github.com/iwillfightfordream/youtube-music-discord-rpc",
label: "Download from GitHub"
}
]
}
)
return
}
rpcClient.setActivity(
{
smallImageText: state[playbackState],
smallImageKey: photos[playbackState],
largeImageText: finalDetails,
type: 4,
details: title,
state: author,
startTimestamp: startTime,
endTimestamp: endTime,
largeImageKey: photo,
buttons: [
{
url: videoLink,
label: "Play Video"
},
{
url: "https://github.com/iwillfightfordream/youtube-music-discord-rpc",
label: "Download from GitHub"
}
]
}
)
return
}
if (author == "") {
rpcClient.setActivity(
{
smallImageText: state[playbackState],
smallImageKey: photos[playbackState],
largeImageText: finalDetails,
type: 4,
details: title,
startTimestamp: startTime,
endTimestamp: endTime,
largeImageKey: photo
}
)
return
}
rpcClient.setActivity(
{
smallImageText: state[playbackState],
smallImageKey: photos[playbackState],
largeImageText: finalDetails,
type: 4,
details: title,
state: author,
startTimestamp: startTime,
endTimestamp: endTime,
largeImageKey: photo
}
)
return
}

module.exports.setSearchActivity = (query) => {
if (rpcClient == null) {
if (rpcClient !== null) return
this.connect()
}

const startTime = Date.now() - progress * 1000

rpcClient.setActivity(
{
smallImageText: "Searching",
smallImageKey: "search",
largeImageText: "YouTube Music",
type: 4,
details: "Searching on YouTube Music",
state: query,
startTimestamp: startTime,
largeImageKey: "largebadge"
}
)
return
}
Binary file added icon.ico
Binary file not shown.
Loading

0 comments on commit 9685171

Please sign in to comment.