Skip to content

Instantly share code, notes, and snippets.

@jhbruhn
Forked from cjmoeller/Pedas Whatsremote.js
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhbruhn/dc56c86fe79a76c05c11 to your computer and use it in GitHub Desktop.
Save jhbruhn/dc56c86fe79a76c05c11 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name My Fancy New Userscript
// @namespace https://whatsremote.com/*
// @version 0.1
// @description Peda B's house
// @match http://tampermonkey.net/
// @include https://whatsremote.net/*
// @require http://audiocogs.org/codecs/js/aurora.js
// @require http://audiocogs.org/codecs/js/aac.js
// @copyright 2014, PedaB
// ==/UserScript==
function loadScript(url, callback)
{
// Adding the script tag to the head as suggested before
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
// Then bind the event to the callback function.
// There are several events for cross browser compatibility.
script.onreadystatechange = callback;
script.onload = callback;
// Fire the loading
head.appendChild(script);
}
function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
var temp = 0;
function update() {
urls = document.getElementsByTagName("a");
for ( var i = 0; i < urls.length; i++) {
var url = urls[i];
if (endsWith(url.href, "aac")) {
if (!(url.hasAttribute("id"))) {
console.log("Replacing: "+ "player"+temp);
console.log(url);
url.setAttribute("id", "player"+temp);
jwplayer(url.id).setup({
file: url.href,
width: 200,
height: 10
});
}
}
temp++;
}
}
function ready()
{
var _sampleRate = (function() {
var AudioContext = (window.AudioContext || window.webkitAudioContext);
if (!AudioContext)
return 44100;
return new AudioContext().sampleRate;
}());
setInterval(update, 1000);
}
loadScript("https://jwpsrv.com/library/eI6zhBszEeS89yIACtqXBA.js", ready);
console.log("Peda");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment