Skip to content

Instantly share code, notes, and snippets.

@adammw
Created January 23, 2016 22:54
Show Gist options
  • Save adammw/483f9bfa44251b3e3901 to your computer and use it in GitHub Desktop.
Save adammw/483f9bfa44251b3e3901 to your computer and use it in GitHub Desktop.
// https://app.sm-app.co/static/js/player.js
// this script is injected into the netflix player page
// minified versions of jQuery and arrive.js removed, the ipc object communicates with scripts on https://app.sm-app.co/
var html_element;
console.log("Injected player.js is now running...");
html_element = document.getElementsByTagName("html")[0];
/mac/i.test(navigator.platform) ? html_element.setAttribute("class", "mac") : /win/i.test(navigator.platform) && html_element.setAttribute("class", "win");
$(function() {
return $(document).on("click", ".player-exit-playback, .player-back-to-browsing", function(a) {
return a.preventDefault(), ipc.sendToHost("close")
}), $(document).arrive(".player-fatal-message", {
onceOnly: !0,
existing: !0
}, function() {
var a;
return $(this).find("h3 > span").length ? (a = $(this).find("h3 > span").text(), console.log("Netflix Error: " + a), ipc.sendToHost("netflix-error", a)) : void 0
}), $(document).arrive(".signupBasicHeader", {
onceOnly: !0,
existing: !0
}, function() {
return ipc.sendToHost("login-required")
}), $(document).arrive(".player-progress-loading", {
onceOnly: !0,
existing: !0
}, function() {
return delay(400, function() {
return ipc.sendToHost("ready")
})
}), $(document).arrive(".player-autoplay-interrupter", function() {
return $(this).find("button.button.continue-playing").click()
}), $(document).arrive(".player-postplay", function() {
return $(".player-postplay-show-autoplay").length ? $(".player-postplay-show-autoplay .postplay-still-container").click() : ipc.sendToHost("close")
}), $(document).arrive(".player-timed-text-tracks", function() {
return $(this).children().filter(function() {
return "Off" === $(this).text() || "none" === $(this).data("id")
}).length ? void 0 : ($('<li class="forced-off-subtitles">Off</li>').insertAfter(".player-timed-text-tracks lh"), $(".player-timed-text-tracks").on("click", "li", function() {
return $(this).hasClass("forced-off-subtitles") ? ($(this).siblings("li.player-track-selected").removeClass("player-track-selected"), $(".player-timedtext").addClass("hide-timedtext")) : ($(".player-timedtext").removeClass("hide-timedtext"), $(this).siblings("li.forced-off-subtitles").removeClass("player-track-selected")), $(this).addClass("player-track-selected")
}))
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment