Created
April 15, 2015 11:01
-
-
Save wolph/6e49ac1ecffd88c63eb4 to your computer and use it in GitHub Desktop.
Userscript to play files in external media player
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Play in external player | |
// @namespace http://wol.ph/ | |
// @version 1.0 | |
// @grant GM_getValue | |
// @grant GM_openInTab | |
// @grant GM_registerMenuCommand | |
// @grant GM_setValue | |
// @include http://* | |
// @include https://* | |
// @copyright 2015, Wolph | |
// ==/UserScript== | |
function getDomains(){ | |
return GM_getValue('domains', ''); | |
} | |
function setDomains(domains){ | |
if(domains !== null)return GM_setValue('domains', domains); | |
} | |
function getPlayerPrefix(){ | |
return GM_getValue('player_prefix', 'mpv://'); | |
} | |
function setPlayerPrefix(prefix){ | |
if(domains !== null)return GM_setValue('player_prefix', prefix); | |
} | |
function getPlayerPostfix(){ | |
return GM_getValue('player_postfix', ''); | |
} | |
function setPlayerPostfix(postfix){ | |
if(domains !== null)return GM_setValue('player_postfix', postfix); | |
} | |
function configureDomains(){ | |
setDomains(prompt("Enabled domains (regular expression, separate by '|'): ", getDomains())); | |
} | |
function configurePlayer(){ | |
setPlayerPrefix(prompt("Set the player prefix: ", getPlayerPrefix())); | |
setPlayerPostfix(prompt("Set the player postfix: ", getPlayerPostfix())); | |
} | |
GM_registerMenuCommand("External player domains", configureDomains); | |
GM_registerMenuCommand("External player", configurePlayer); | |
if(document.location.hostname.match(getDomains())){ | |
window.setTimeout(function(){ | |
try{ | |
$('.jwplayer').after( | |
'<a href="' + getPlayerPrefix() + __fileurl | |
+ getPlayerPostfix() + '">Play local</a>'); | |
}catch(e){ | |
}; | |
}, 500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment