Created
January 10, 2018 06:49
-
-
Save ketra/a734fde4da38c879e3a79b1d54c78114 to your computer and use it in GitHub Desktop.
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 netflix-sync | |
// @namespace https://github.com/MrDemocracy/netflix-sync | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://www.netflix.com/viewingactivity* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var header = document.getElementById('hd'); | |
var element = document.querySelector("li[data-reactid='20']"); | |
var btn = document.createElement("li"); | |
var t = document.createTextNode("Sync"); | |
btn.className = "profile-selector"; | |
btn.appendChild(t); | |
insertAfter(btn,element); | |
btn.addEventListener("click", function() { | |
load('https://rawgit.com/MrDemocracy/netflix-sync/master/jquery-ui.js', 'js'); | |
load('https://rawgit.com/MrDemocracy/netflix-sync/master/netflix-sync.js','js'); | |
load('https://rawgit.com/MrDemocracy/netflix-sync/master/netflix-sync.css','css'); | |
}, false); | |
function load(filename){ | |
if(filename.endsWith('.js')){ | |
var fileref=document.createElement('script'); | |
fileref.setAttribute('type','text/javascript'); | |
fileref.setAttribute('src',filename); | |
} | |
else if (filename.endsWith('.css')){ | |
var fileref=document.createElement('link'); | |
fileref.setAttribute('rel','stylesheet'); | |
fileref.setAttribute('type','text/css'); | |
fileref.setAttribute('href',filename); | |
} | |
document.getElementsByTagName('head')[0].appendChild(fileref); | |
} | |
function insertAfter(newNode, referenceNode) { | |
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment