Skip to content

Instantly share code, notes, and snippets.

@jhickman
Last active September 13, 2018 13:48
Show Gist options
  • Save jhickman/a8db4c013047efc8f4985372b3cbf200 to your computer and use it in GitHub Desktop.
Save jhickman/a8db4c013047efc8f4985372b3cbf200 to your computer and use it in GitHub Desktop.
//
// Hulu.plist
// BeardedSpice
//
// Created by Justin Hickman on 2018-09-13.
//
// strategy/site notes
// - favorite, not implemented on this site
// - next/prev uses the fastforward and rewind button elements click() event this will do the 10 second skipping.
// - track info uses first and second line elements as well as the network logo (currently disabled)
// - The logo is diabled because Hulu doesn't update the metadata properly. If new video doesn't have an image, it keeps the old one.
BSStrategy = {
version:1,
displayName:"Hulu",
accepts: {
method: "predicateOnTab",
format:"%K LIKE[c] '*hulu.com/*'",
args: ["URL"]
},
isPlaying:function () {
var v=document.querySelector('video');
return v && ! v.paused;
},
toggle:function () {
var v=document.querySelector('video');
if (v) {v.paused ? v.play() : v.pause();}
},
next: function () {
var ffButton=document.querySelector('.controls__fastforward-button');
ffButton.click();
},
favorite: function () {},
previous: function () {
var rwButton=document.querySelector('.controls__rewind-button');
rwButton.click();
},
pause:function () {
var v=document.querySelector('video');
v && v.pause();
},
trackInfo: function () {
var firstLine=document.querySelector('.metadata-area__first-line');
var secondLine=document.querySelector('.metadata-area__second-line');
var logo=document.querySelector('.metadata-area__network-logo');
return {
'album': firstLine ? firstLine.innerText : '',
'track': secondLine ? secondLine.innerText : '',
'image': '#',
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment