Skip to content

Instantly share code, notes, and snippets.

@olijf
Created February 6, 2021 13:46
Show Gist options
  • Save olijf/187b5480e12b4afa245dc60ed7d5bd0d to your computer and use it in GitHub Desktop.
Save olijf/187b5480e12b4afa245dc60ed7d5bd0d to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Fosdem Chromecastplayer
// @version 1.0
// @description Adds link to cast to Chromecast using Chromecast.link
// @match live.fosdem.org/watch*
// @copyright 2021, Olaf
// ==/UserScript==
function _x(STR_XPATH) {
var xresult = document.evaluate(STR_XPATH, document, null, XPathResult.ANY_TYPE, null);
var xnodes = [];
var xres;
while (xres = xresult.iterateNext()) {
xnodes.push(xres);
}
return xnodes;
}
(function() {
'use strict';
var child = _x('/html/body/div[3]/p[2]/a[1]')
var blah = document.createElement('a')
blah.setAttribute('href', 'https://chromecast.link/#content=' + encodeURI(child[0].href))
blah.innerHTML = '<br/>Cast!'
child[0].append(blah)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment