new plugin
This commit is contained in:
parent
77e5f359f2
commit
eba4c61168
|
@ -4258,6 +4258,18 @@
|
|||
error: "error-k9z2IV",
|
||||
overlay: "spellCheckOverlay-cNSap5"
|
||||
};
|
||||
DiscordClassModules.SpotifyControls = {
|
||||
bar: "bar-g2ZMIm",
|
||||
barContainer: "barContainer-UWmgAx",
|
||||
barFill: "barFill-Dhkah7",
|
||||
barText: "barText-lmqc5O",
|
||||
container: "container-6sXIoE",
|
||||
containerInner: "inner-WRV6k5",
|
||||
cover: "cover-SwJ-ck",
|
||||
details: "details-ntX2k5",
|
||||
interpret: "interpret-F93iqP",
|
||||
song: "song-tIdBpF",
|
||||
};
|
||||
DiscordClassModules.TimedLightDarkMode = {
|
||||
dateGrabber: "dateGrabber-QrRkIX",
|
||||
timerGrabber: "timerGrabber-zpRAIk",
|
||||
|
@ -4609,6 +4621,16 @@
|
|||
_showimagedetailsdetails: ["ShowImageDetails", "details"],
|
||||
_spellcheckerror: ["SpellCheck", "error"],
|
||||
_spellcheckoverlay: ["SpellCheck", "overlay"],
|
||||
_spotifycontrolsbar: ["SpotifyControls", "bar"],
|
||||
_spotifycontrolsbarcontainer: ["SpotifyControls", "barContainer"],
|
||||
_spotifycontrolsbarfill: ["SpotifyControls", "barFill"],
|
||||
_spotifycontrolsbartext: ["SpotifyControls", "barText"],
|
||||
_spotifycontrolscontainer: ["SpotifyControls", "container"],
|
||||
_spotifycontrolscontainerinner: ["SpotifyControls", "containerInner"],
|
||||
_spotifycontrolscover: ["SpotifyControls", "cover"],
|
||||
_spotifycontrolsdetails: ["SpotifyControls", "details"],
|
||||
_spotifycontrolsinterpret: ["SpotifyControls", "interpret"],
|
||||
_spotifycontrolssong: ["SpotifyControls", "song"],
|
||||
_timedlightdarkmodedategrabber: ["TimedLightDarkMode", "dateGrabber"],
|
||||
_timedlightdarkmodetimergrabber: ["TimedLightDarkMode", "timerGrabber"],
|
||||
_timedlightdarkmodetimersettings: ["TimedLightDarkMode", "timerSettings"],
|
||||
|
@ -6451,7 +6473,7 @@
|
|||
});
|
||||
let parseLanguageStringObj = obj => {
|
||||
let string = "";
|
||||
if (typeof obj == "string") string += BDFDB.StringUtils.htmlEscape(obj);
|
||||
if (typeof obj == "string") string += obj;
|
||||
else if (BDFDB.ObjectUtils.is(obj)) {
|
||||
if (obj.props) string += parseLanguageStringObj(obj.props);
|
||||
else if (obj.type) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -51,6 +51,7 @@
|
|||
- [Show Hidden Channels](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ShowHiddenChannels) - Displays all hidden channels that can't be accessed due to role restrictions in a new category.
|
||||
- [Show Image Details](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ShowImageDetails) - Display the name, size and dimensions of uploaded images (does not include embed images) in the chat as an header or as a tooltip.
|
||||
- [Spell Check](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/SpellCheck) - Adds a spellcheck to all textareas.
|
||||
- [Spotify Controls](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/SpotifyControls) - Adds a control panel to discord when listening to spotify.
|
||||
- [Steam Profile Link](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/SteamProfileLink) - Opens a steam profile in steam instead of a browser when clicking the steamlink in a userprofile. With the help of square.
|
||||
- [Theme Repo](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ThemeRepo) - Allows you to preview all themes from the theme repo and download them on the fly.
|
||||
- [Theme Settings](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ThemeSettings) - Allows you to change Theme Variables within BetterDiscord.
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
# Spotify Controls - [![Downlad][download-badge]][download-link] [![Paypal][paypal-badge]][paypal-link] [![Patreon][patreon-badge]][patreon-link]
|
||||
|
||||
[download-badge]: https://img.shields.io/badge/Download-Plugin-brightgreen.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAACXBIWXMAAA7EAAAOxAGVKw4bAAADGGlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjaY2BgnuDo4uTKJMDAUFBUUuQe5BgZERmlwH6egY2BmYGBgYGBITG5uMAxIMCHgYGBIS8/L5UBFTAyMHy7xsDIwMDAcFnX0cXJlYE0wJpcUFTCwMBwgIGBwSgltTiZgYHhCwMDQ3p5SUEJAwNjDAMDg0hSdkEJAwNjAQMDg0h2SJAzAwNjCwMDE09JakUJAwMDg3N+QWVRZnpGiYKhpaWlgmNKflKqQnBlcUlqbrGCZ15yflFBflFiSWoKAwMD1A4GBgYGXpf8EgX3xMw8BSMDVQYqg4jIKAUICxE+CDEESC4tKoMHJQODAIMCgwGDA0MAQyJDPcMChqMMbxjFGV0YSxlXMN5jEmMKYprAdIFZmDmSeSHzGxZLlg6WW6x6rK2s99gs2aaxfWMPZ9/NocTRxfGFM5HzApcj1xZuTe4FPFI8U3mFeCfxCfNN45fhXyygI7BD0FXwilCq0A/hXhEVkb2i4aJfxCaJG4lfkaiQlJM8JpUvLS19QqZMVl32llyfvIv8H4WtioVKekpvldeqFKiaqP5UO6jepRGqqaT5QeuA9iSdVF0rPUG9V/pHDBYY1hrFGNuayJsym740u2C+02KJ5QSrOutcmzjbQDtXe2sHY0cdJzVnJRcFV3k3BXdlD3VPXS8Tbxsfd99gvwT//ID6wIlBS4N3hVwMfRnOFCEXaRUVEV0RMzN2T9yDBLZE3aSw5IaUNak30zkyLDIzs+ZmX8xlz7PPryjYVPiuWLskq3RV2ZsK/cqSql01jLVedVPrHzbqNdU0n22VaytsP9op3VXUfbpXta+x/+5Em0mzJ/+dGj/t8AyNmf2zvs9JmHt6vvmCpYtEFrcu+bYsc/m9lSGrTq9xWbtvveWGbZtMNm/ZarJt+w6rnft3u+45uy9s/4ODOYd+Hmk/Jn58xUnrU+fOJJ/9dX7SRe1LR68kXv13fc5Nm1t379TfU75/4mHeY7En+59lvhB5efB1/lv5dxc+NH0y/fzq64Lv4T8Ffp360/rP8f9/AA0ADzT6lvFdAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAF1SURBVHja7JihTgNBEIb/K1WkBtEEAsESBKEvgEKRAhLHOxAMfQ9cHwEMBoFA1/ACBEGgzbkmUAwI+BENubTs9WZmLz1CZtZd9v7/u9vMZGdAGFabA05Hn3sWrYQwRB9rwafreikbQN5LiV6qhorDARzAARzAARzAARzAARzAARygGOAQ6a+GLr9jmlwpDuJbsxQrER+YYrXaI2D8EZyAEfangj2Fq0NrnBWry8YI5yb7rkRbBrDAK7X9NevlAYCL7Kns79iQKcunOU0+iO0fuSzV1QyUNjkU2b9wS66qm2nt8L3Q/oO7Gk3tWO2InzPtv3isU9RP9jqxmR8LMKsqdPVqFoC8qiDM/HiAcFUQZ34IYDr0VUGW+QEfK8BkVZBmfqkAWVWQZ37JAOA+n/nEtnh/wGd8JWP81Nt0P0r8Wu4ADvAHAOq2fsaP4N8BvFXi/ZoB3FYCcJMNKDbQw9Kc7YdoYfDzB+6xjUuM5mY+wsXYHvgeABIzsPkSOM/lAAAAAElFTkSuQmCC&style=flat
|
||||
[download-link]: https://betterdiscord.net/ghdl?url=https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/SpotifyControls/SpotifyControls.plugin.js
|
||||
|
||||
[paypal-badge]: https://img.shields.io/badge/Paypal-Donate!-%23003087.svg?logo=paypal&style=flat
|
||||
[paypal-link]: https://paypal.me/MircoWittrien
|
||||
|
||||
[patreon-badge]: https://img.shields.io/badge/Patreon-Support!-%23F96854.svg?logo=patreon&style=flat
|
||||
[patreon-link]: https://patreon.com/MircoWittrien
|
||||
|
||||
Adds a control panel to discord when listening to spotify.
|
|
@ -0,0 +1,332 @@
|
|||
//META{"name":"SpotifyControls","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/SpotifyControls","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/SpotifyControls/SpotifyControls.plugin.js"}*//
|
||||
|
||||
var SpotifyControls = (_ => {
|
||||
var controls, lastSong, updateInterval;
|
||||
|
||||
const SpotifyControlsComponent = class SpotifyControls extends BdApi.React.Component {
|
||||
componentDidMount() {
|
||||
controls = this;
|
||||
}
|
||||
request(socket, device, type, song, data) {
|
||||
return new Promise(callback => {
|
||||
BDFDB.LibraryRequires.request({
|
||||
url: `https://api.spotify.com/v1/me/player/${type}`,
|
||||
method: type == "next" || type == "previous" ? "POST" : "PUT",
|
||||
query: {device_id: device.id},
|
||||
headers: {
|
||||
authorization: `Bearer ${socket.accessToken}`
|
||||
},
|
||||
body: JSON.stringify(Object.assign({
|
||||
context_uri: song && song.metadata.context_uri || null
|
||||
}, data))
|
||||
}, (error, response, result) => {
|
||||
if (error && reponse.statusCode == 401) {
|
||||
BDFDB.LibraryModules.SpotifyUtils.getAccessToken(socket.accountId).then(promiseResult => {
|
||||
let newSocketDevice = BDFDB.LibraryModules.SpotifyTrackUtils.getActiveSocketAndDevice();
|
||||
this.request(newSocketDevice.socket, newSocketDevice.device, type, song, data).then(_ => {
|
||||
callback(error, response, result);
|
||||
});
|
||||
});
|
||||
}
|
||||
else callback(error, response, result);
|
||||
});
|
||||
});
|
||||
}
|
||||
render() {
|
||||
let socketDevice = BDFDB.LibraryModules.SpotifyTrackUtils.getActiveSocketAndDevice();
|
||||
if (this.props.song) lastSong = this.props.song;
|
||||
return !socketDevice || !lastSong ? null : BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._spotifycontrolscontainer,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._spotifycontrolscontainerinner,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement("img", {
|
||||
className: BDFDB.disCN._spotifycontrolscover,
|
||||
src: BDFDB.LibraryModules.AssetUtils.getAssetImage(lastSong.application_id, lastSong.assets.large_image, [128, 128])
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._spotifycontrolsdetails,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextElement, {
|
||||
className: BDFDB.disCN._spotifycontrolssong,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
|
||||
children: lastSong.details
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextElement, {
|
||||
className: BDFDB.disCNS.subtext + BDFDB.disCN._spotifycontrolsinterpret,
|
||||
color: BDFDB.LibraryComponents.TextElement.Colors.CUSTOM,
|
||||
size: BDFDB.LibraryComponents.TextElement.Sizes.SIZE_12,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
|
||||
children: BDFDB.LanguageUtils.LanguageStringsFormat("USER_ACTIVITY_LISTENING_ARTISTS", lastSong.state)
|
||||
})
|
||||
})
|
||||
]
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
||||
text: socketDevice.device.is_restricted ? "Can not control Spotify while playing on restricted device" : null,
|
||||
tooltipConfig: {color: "red"},
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
grow: 0,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
|
||||
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.accountinfobutton, !socketDevice.device.is_restricted ? BDFDB.disCN.accountinfobuttonenabled : BDFDB.disCN.accountinfobuttondisabled),
|
||||
style: {fontFamily: "glue1-spoticon"},
|
||||
look: BDFDB.LibraryComponents.Button.Looks.BLANK,
|
||||
size: BDFDB.LibraryComponents.Button.Sizes.NONE,
|
||||
children: "",
|
||||
onClick: socketDevice.device.is_restricted ? _ => {} : _ => {
|
||||
this.request(socketDevice.socket, socketDevice.device, "previous");
|
||||
}
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
|
||||
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.accountinfobutton, !socketDevice.device.is_restricted ? BDFDB.disCN.accountinfobuttonenabled : BDFDB.disCN.accountinfobuttondisabled),
|
||||
style: {fontFamily: "glue1-spoticon"},
|
||||
look: BDFDB.LibraryComponents.Button.Looks.BLANK,
|
||||
size: BDFDB.LibraryComponents.Button.Sizes.NONE,
|
||||
children: this.props.song ? "" : "",
|
||||
onClick: socketDevice.device.is_restricted ? _ => {} : _ => {
|
||||
if (this.props.song) this.request(socketDevice.socket, socketDevice.device, "pause");
|
||||
else this.request(socketDevice.socket, socketDevice.device, "play", lastSong);
|
||||
}
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
|
||||
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.accountinfobutton, !socketDevice.device.is_restricted ? BDFDB.disCN.accountinfobuttonenabled : BDFDB.disCN.accountinfobuttondisabled),
|
||||
style: {fontFamily: "glue1-spoticon"},
|
||||
look: BDFDB.LibraryComponents.Button.Looks.BLANK,
|
||||
size: BDFDB.LibraryComponents.Button.Sizes.NONE,
|
||||
children: "",
|
||||
onClick: socketDevice.device.is_restricted ? _ => {} : _ => {
|
||||
this.request(socketDevice.socket, socketDevice.device, "next");
|
||||
}
|
||||
})
|
||||
]
|
||||
})
|
||||
})
|
||||
]
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(SpotifyControlsTimelineComponent, {
|
||||
song: lastSong
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
const SpotifyControlsTimelineComponent = class SpotifyControlsTimeline extends BdApi.React.Component {
|
||||
componentDidMount() {
|
||||
BDFDB.TimeUtils.clear(updateInterval);
|
||||
updateInterval = BDFDB.TimeUtils.interval(_ => {
|
||||
if (!this.updater || typeof this.updater.isMounted != "function" || !this.updater.isMounted(this)) BDFDB.TimeUtils.clear(updateInterval);
|
||||
else BDFDB.ReactUtils.forceUpdate(this);
|
||||
}, 1000);
|
||||
}
|
||||
formatTime(time) {
|
||||
let seconds = Math.floor((time / 1000) % 60);
|
||||
let minutes = Math.floor((time / (1000 * 60)) % 60);
|
||||
let hours = Math.floor((time / (1000 * 60 * 60)) % 24);
|
||||
return `${hours > 0 ? hours + ":" : ""}${hours > 0 && minutes < 10 ? "0" + minutes : minutes}:${seconds < 10 ? "0" + seconds : seconds}`
|
||||
}
|
||||
render() {
|
||||
let currentTime = new Date() - this.props.song.timestamps.start;
|
||||
let maxTime = this.props.song.timestamps.end - this.props.song.timestamps.start;
|
||||
return BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._spotifycontrolsbarcontainer,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._spotifycontrolsbar,
|
||||
children: BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._spotifycontrolsbarfill,
|
||||
style: {width: `${currentTime / maxTime * 100}%`}
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._spotifycontrolsbartext,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextElement, {
|
||||
className: BDFDB.disCN.height12,
|
||||
size: BDFDB.LibraryComponents.TextElement.Sizes.SIZE_12,
|
||||
children: this.formatTime(currentTime)
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextElement, {
|
||||
className: BDFDB.disCN.height12,
|
||||
size: BDFDB.LibraryComponents.TextElement.Sizes.SIZE_12,
|
||||
children: this.formatTime(maxTime)
|
||||
})
|
||||
]
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return class SpotifyControls {
|
||||
getName () {return "SpotifyControls";}
|
||||
|
||||
getVersion () {return "1.0.0";}
|
||||
|
||||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Adds a control panel to discord when listening to spotify.";}
|
||||
|
||||
constructor () {
|
||||
this.patchedModules = {
|
||||
after: {
|
||||
AnalyticsContext: "render"
|
||||
}
|
||||
};
|
||||
|
||||
this.css = `
|
||||
@font-face {
|
||||
font-family: glue1-spoticon;
|
||||
src: url("https://mwittrien.github.io/BetterDiscordAddons/Plugins/SpotifyControls/res/spoticon.ttf") format("truetype");
|
||||
font-weight: 400;
|
||||
font-style: normal
|
||||
}
|
||||
${BDFDB.dotCN._spotifycontrolscontainer} {
|
||||
margin-bottom: 1px;
|
||||
border-bottom: 1px solid var(--background-modifier-accent);
|
||||
padding: 8px 8px 0 8px;
|
||||
}
|
||||
${BDFDB.dotCN._spotifycontrolscontainerinner} {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 14px;
|
||||
}
|
||||
${BDFDB.dotCN._spotifycontrolsbarcontainer} {
|
||||
margin: 4px 0;
|
||||
}
|
||||
${BDFDB.dotCN._spotifycontrolsbar} {
|
||||
border-radius: 2px;
|
||||
background-color: rgba(79, 84, 92, 0.16);
|
||||
height: 4px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
${BDFDB.dotCN._spotifycontrolsbarfill} {
|
||||
border-radius: 2px;
|
||||
height: 100%;
|
||||
min-width: 4px;
|
||||
border-radius: 2px;
|
||||
background: var(--header-primary);
|
||||
}
|
||||
${BDFDB.dotCN._spotifycontrolsbartext} {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
${BDFDB.dotCN._spotifycontrolscover} {
|
||||
display: block;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
margin-right: 8px;
|
||||
border-radius: 4px;
|
||||
object-fit: cover;
|
||||
}
|
||||
${BDFDB.dotCN._spotifycontrolsdetails} {
|
||||
user-select: text;
|
||||
flex-grow: 1;
|
||||
margin-right: 4px;
|
||||
min-width: 0;
|
||||
}
|
||||
${BDFDB.dotCN._spotifycontrolssong} {
|
||||
font-weight: 500;
|
||||
}
|
||||
${BDFDB.dotCN._spotifycontrolsinterpret} {
|
||||
font-weight: 300;
|
||||
}
|
||||
${BDFDB.dotCNS._spotifycontrolscontainer + BDFDB.dotCN.accountinfobuttondisabled}{
|
||||
pointer: no-drop;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
initConstructor () {}
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
}
|
||||
|
||||
// Legacy
|
||||
load () {}
|
||||
|
||||
start () {
|
||||
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
|
||||
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
|
||||
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
|
||||
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
|
||||
if (libraryScript) libraryScript.remove();
|
||||
libraryScript = document.createElement("script");
|
||||
libraryScript.setAttribute("id", "BDFDBLibraryScript");
|
||||
libraryScript.setAttribute("type", "text/javascript");
|
||||
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
|
||||
libraryScript.setAttribute("date", performance.now());
|
||||
libraryScript.addEventListener("load", _ => {this.initialize();});
|
||||
document.head.appendChild(libraryScript);
|
||||
}
|
||||
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
|
||||
this.startTimeout = setTimeout(_ => {
|
||||
try {return this.initialize();}
|
||||
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
|
||||
}, 30000);
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.PluginUtils.init(this);
|
||||
|
||||
BDFDB.ModuleUtils.patch(this, BDFDB.LibraryModules.SpotifyTrackUtils, "getActivity", {after: e => {
|
||||
if (e.returnValue && e.returnValue.name == "Spotify") this.updatePlayer(e.returnValue);
|
||||
else if (!e.returnValue) this.updatePlayer(null);
|
||||
}});
|
||||
|
||||
BDFDB.ModuleUtils.patch(this, BDFDB.LibraryModules.SpotifyTrackUtils, "wasAutoPaused", {instead: e => {
|
||||
return false;
|
||||
}});
|
||||
|
||||
BDFDB.ModuleUtils.patch(this, BDFDB.LibraryModules.SpotifyUtils, "pause", {instead: e => {
|
||||
return false;
|
||||
}});
|
||||
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
|
||||
}
|
||||
}
|
||||
|
||||
stop () {
|
||||
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
this.stopping = true;
|
||||
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
|
||||
BDFDB.PluginUtils.clear(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Begin of own functions
|
||||
|
||||
processAnalyticsContext (e) {
|
||||
if (typeof e.returnvalue.props.children == "function" && e.instance.props.section == BDFDB.DiscordConstants.AnalyticsSections.ACCOUNT_PANEL) {
|
||||
let renderChildren = e.returnvalue.props.children;
|
||||
e.returnvalue.props.children = (...args) => {
|
||||
return [
|
||||
BDFDB.ReactUtils.createElement(SpotifyControlsComponent, {
|
||||
song: BDFDB.LibraryModules.SpotifyTrackUtils.getActivity()
|
||||
}),
|
||||
renderChildren(...args)
|
||||
];
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
updatePlayer (song) {
|
||||
if (controls) {
|
||||
controls.props.song = song;
|
||||
BDFDB.ReactUtils.forceUpdate(controls);
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
Binary file not shown.
Loading…
Reference in New Issue