-
-
Save FrostBird347/6abad7503698db0c95a94ad3a2d0ca6c to your computer and use it in GitHub Desktop.
| /** | |
| * @name VideoLoop | |
| * @authorLink https://github.com/FrostBird347 | |
| * @source https://gist.github.com/FrostBird347/6abad7503698db0c95a94ad3a2d0ca6c#gistcomment-3640733 | |
| * @updateUrl https://gist.githubusercontent.com/FrostBird347/6abad7503698db0c95a94ad3a2d0ca6c/raw/VideoLoop.plugin.js | |
| */ | |
| module.exports = class VideoLoop { | |
| getName () {return "VideoLoop";} | |
| getDescription () {return "Adds a replay button next to the pause button in discord videos audio files.";} | |
| getVersion() {return "1.1.8";} | |
| getAuthor () {return "FrostBird347";} | |
| load() {} | |
| stop() {} | |
| start() { | |
| //Simple update notifier | |
| //I have been unable to figure out how to obtain the plugin's version | |
| let CurrentVersion = "1.1.8" | |
| window.fetch("https://gist.githubusercontent.com/FrostBird347/6abad7503698db0c95a94ad3a2d0ca6c/raw/VideoLoop.plugin.js").then(function(response) { | |
| response.text().then(function(text) { | |
| let Lines = text.split("\t").join("").split("\n") | |
| let RemoteVersion = "" | |
| for (let l = 0; l < Lines.length; l++) { | |
| if (RemoteVersion == "" && Lines[l].split(" ").join("").split("\"")[0] == "getVersion(){return") { | |
| RemoteVersion = Lines[l].split(" ").join("").split("\"")[1] | |
| } | |
| } | |
| if (RemoteVersion != CurrentVersion) { | |
| window.BdApi.UI.showToast("VideoLoop is outdated!\nCurrent: " + CurrentVersion + "\nLatest: " + RemoteVersion, {type: "info", icon:true, timeout: 7500}) | |
| } | |
| }) | |
| }) | |
| } | |
| observer(changes) { | |
| let ElementClasses = { | |
| "videoControls": "videoControls__7bc92", | |
| "controlIcon": "controlIcon_d1bbd7", | |
| "audioControls": "audioControls_da7066" | |
| } | |
| Array.prototype.forEach.call(document.querySelectorAll("[class*=" + ElementClasses.videoControls + "]"), function(el) { | |
| try { | |
| if (!el.classList.contains("AddedLoop")) { | |
| el.classList.add("AddedLoop") | |
| el.insertBefore(document.createElement("div"), el.children[1]) | |
| el.children[1].innerHTML = '<svg class="' + ElementClasses.controlIcon + '" aria-hidden="false" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="m 17.673205,7.3499186 2.828428,-2.8284271 h -7.071068 v 7.0710675 l 2.828427,-2.8284268 c 2.340523,2.3405238 2.340523,6.1447578 -2e-6,8.4852828 -2.340524,2.340524 -6.144758,2.340524 -8.4852815,1e-6 -2.3405235,-2.340524 -2.3405234,-6.144758 5e-7,-8.4852824 L 6.3594955,7.34992 c -3.1254128,3.125413 -3.1254126,8.188297 -7e-7,11.313709 3.125412,3.125412 8.1882962,3.125412 11.3137092,0 3.125413,-3.125414 3.125413,-8.188298 1e-6,-11.3137104 z M 6.3267946,18.696329 3.4983675,21.524757 h 7.0710675 v -7.071068 l -2.8284268,2.828427 c -2.3405235,-2.340524 -2.3405235,-6.144758 0,-8.4852815 2.3405238,-2.3405235 6.1447578,-2.3405235 8.4852818,0 2.340523,2.3405235 2.340523,6.1447575 0,8.4852815 l 1.414213,1.414213 c 3.125412,-3.125412 3.125412,-8.188296 0,-11.3137081 -3.125412,-3.125412 -8.1882964,-3.125412 -11.3137084,0 -3.125412,3.1254121 -3.125412,8.1882961 0,11.3137081 z"></path></svg>' | |
| el.children[1].id = "VideoLoopButton" | |
| el.children[1].onclick = function(preel) { | |
| let el = preel.srcElement | |
| if (el.tagName.toLowerCase() == "path") { | |
| el = el.parentElement | |
| } | |
| if (!el.parentElement.classList.contains("ChangingLoop")) { | |
| el.parentElement.classList.add("ChangingLoop") | |
| let videl = el | |
| videl = el.parentElement.parentElement.parentElement.parentElement.querySelector("VIDEO") | |
| if (videl.tagName != "VIDEO") { | |
| el.remove() | |
| } else { | |
| if (videl.loop) { | |
| el.style.color = "" | |
| el.style.opacity = "" | |
| videl.loop = false | |
| } else { | |
| el.style.color = "var(--brand-experiment)" | |
| el.style.opacity = 1 | |
| videl.loop = true | |
| } | |
| } | |
| el.parentElement.classList.remove("ChangingLoop") | |
| } | |
| } | |
| } | |
| } catch {} | |
| }) | |
| Array.prototype.forEach.call(document.querySelectorAll("[class*=" + ElementClasses.audioControls + "]"), function(el) { | |
| try { | |
| if (!el.classList.contains("AddedLoop")) { | |
| el.classList.add("AddedLoop") | |
| el.insertBefore(document.createElement("div"), el.children[1]) | |
| el.children[1].innerHTML = '<svg class="' + ElementClasses.controlIcon + '" aria-hidden="false" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="m 17.673205,7.3499186 2.828428,-2.8284271 h -7.071068 v 7.0710675 l 2.828427,-2.8284268 c 2.340523,2.3405238 2.340523,6.1447578 -2e-6,8.4852828 -2.340524,2.340524 -6.144758,2.340524 -8.4852815,1e-6 -2.3405235,-2.340524 -2.3405234,-6.144758 5e-7,-8.4852824 L 6.3594955,7.34992 c -3.1254128,3.125413 -3.1254126,8.188297 -7e-7,11.313709 3.125412,3.125412 8.1882962,3.125412 11.3137092,0 3.125413,-3.125414 3.125413,-8.188298 1e-6,-11.3137104 z M 6.3267946,18.696329 3.4983675,21.524757 h 7.0710675 v -7.071068 l -2.8284268,2.828427 c -2.3405235,-2.340524 -2.3405235,-6.144758 0,-8.4852815 2.3405238,-2.3405235 6.1447578,-2.3405235 8.4852818,0 2.340523,2.3405235 2.340523,6.1447575 0,8.4852815 l 1.414213,1.414213 c 3.125412,-3.125412 3.125412,-8.188296 0,-11.3137081 -3.125412,-3.125412 -8.1882964,-3.125412 -11.3137084,0 -3.125412,3.1254121 -3.125412,8.1882961 0,11.3137081 z"></path></svg>' | |
| el.children[1].id = "AudioLoopButton" | |
| el.children[1].onclick = function(preel) { | |
| let el = preel.srcElement | |
| if (el.tagName.toLowerCase() == "path") { | |
| el = el.parentElement | |
| } | |
| if (!el.parentElement.classList.contains("ChangingLoop")) { | |
| el.parentElement.classList.add("ChangingLoop") | |
| let audioel = el | |
| audioel = el.parentElement.parentElement.parentElement.parentElement.querySelector("AUDIO") | |
| if (audioel.tagName != "AUDIO") { | |
| el.remove() | |
| } else { | |
| if (audioel.loop) { | |
| el.style.color = "" | |
| el.style.opacity = "" | |
| audioel.loop = false | |
| } else { | |
| el.style.color = "var(--brand-experiment)" | |
| el.style.opacity = 1 | |
| audioel.loop = true | |
| } | |
| } | |
| el.parentElement.classList.remove("ChangingLoop") | |
| } | |
| } | |
| } | |
| } catch {} | |
| }) | |
| } | |
| } |
Does this work for the browser? Or is it only the app itself? I don't understand GitHub well but it doesn't seem to be working for either the browser or the app.
It won't run in the browser on it's own, however it wouldn't be that difficult to modify the plugin to work in the browser.
(Note that this is a betterdiscord plugin)
Thank you so much I just now realized this😭🙏
So remember when I said "I don't understand GitHub well"? I don't, I don't know what I'm doing at all. 😭
- Click on the "View Raw" button in the top right corner of the code (or open on the link).
- Press Command/Control+S or right click and click on "save as"
- Place the file in BetterDiscord's plugin folder, making sure the file name ends in "
.plugin.js" - You can find the plugin folder by opening discord's settings, opening the "plugin" page and then clicking the "Open Plugins Folder" button.
- Once it's added you probably will need to enable it by clicking the checkmark (
)
does not work currently
I haven't used BetterDiscord in a long time and currently have no plans to resume support when I find myself able to run discord's desktop client again. That's not to say what I won't ever provide support again in the future, it's just not planned.
All my plugins have since been rewritten as userscripts and I do provide support for those versions.
Source ↑
Update Log
1.1.8
1.1.7
1.1.6
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.2
1.0.1
1.0.0