Skip to content

Instantly share code, notes, and snippets.

@Kyiro
Created January 24, 2023 02:17
Show Gist options
  • Save Kyiro/bffebdb7b14171147cccaf0c06936125 to your computer and use it in GitHub Desktop.
Save Kyiro/bffebdb7b14171147cccaf0c06936125 to your computer and use it in GitHub Desktop.
Userscript that replaces the KrakenFiles audio player with the browser default
// ==UserScript==
// @name KrakenFiles Alt Player
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Replaces the KrakenFiles audio player with the browser default
// @author Kyiro
// @match *://krakenfiles.com/view/*/file.html
// @icon https://www.google.com/s2/favicons?sz=64&domain=krakenfiles.com
// @grant none
// @run-at document-end
// ==/UserScript==
function replacePlayer(fileURL) {
const coinInfo = document.getElementById("sfPlayer")?.parentElement;
const player = document.createElement("audio");
player.controls = true;
player.src = fileURL;
player.style.width = "100%";
coinInfo.innerHTML = "";
coinInfo.appendChild(player);
}
(function main() {
const scriptTags = document.getElementsByTagName("script");
for (const scriptTag of scriptTags) {
const matches = scriptTag.innerHTML.match(/m4a:\s?'([^']+)'/);
if (!matches || matches.length < 1) continue;
replacePlayer("https:" + matches[1]);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment