Skip to content

Instantly share code, notes, and snippets.

@fa7ad
Created November 24, 2017 14:41
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 fa7ad/14d46e1e8a16f84f6ef6f102fbee73aa to your computer and use it in GitHub Desktop.
Save fa7ad/14d46e1e8a16f84f6ef6f102fbee73aa to your computer and use it in GitHub Desktop.
reset = (cb, interval, timer) ->
if timer then clearInterval timer
setInterval cb, interval
window.jQuery.noConflict() ($) ->
console.info '[sonarr-mpv]', 'Modifying page...'
findTargets = reset modTargets, 1000, findTargets
modtargets = ->
noEl = true
$ '.fc-event.success, .episode-title-cell.renderable'
.each ->
$ @
.off 'click'
.on 'click', (e) =>
setTimeout addMpvLink, 1000
noEl = false
if noEl
do addMpvLink
console.warn '[sonarr-mpv]', 'No supported targets on this page'
findTargets = reset modTargets, 4816, findTargets
addMpvLink = ->
$ '.episode-file-info tbody .renderable.string-cell'
.css 'color', '#00AAFA'
.css 'cursor', 'pointer'
.css 'transition', 'all ease-in 900ms'
.off 'click'
.on 'click', (e) ->
do e.preventDefault
self = $ @
self.css 'color', 'purple'
setTimeout ->
self.css('color', '#00aafa')
, 3000
window.location.replace "mpv://#{self.text().trim()}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment