Created
December 15, 2017 12:12
-
-
Save Necroforger/9386fabf620a3e8817812101aeca8fe3 to your computer and use it in GitHub Desktop.
Krigoapp Userscript
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 Krigoapp-Youtube | |
// @namespace https://youtube.com/ | |
// @version 0.1 | |
// @description Transmit videoURL, videoThumbnail, and videoTitle data to the server | |
// @author Rin | |
// @match https://www.youtube.com/* | |
// @grant GM_xmlhttpRequest | |
// ==/UserScript== | |
(function () { | |
'use strict'; | |
var ytplayer, | |
videoData, | |
videoURL, | |
videoThumbnail; | |
setInterval(function () { | |
ytplayer = document.querySelector("div[id^='player_']") || document.getElementById("movie_player"); | |
videoData = ytplayer.getVideoData(); | |
videoURL = "youtu.be/"+ videoData.video_id; | |
// // Include the playlist ID in the link | |
// if (ytplayer.getPlaylistId() !== "") videoURL += "?list="+ytplayer.getPlaylistId(); | |
videoThumbnail = "https://i.ytimg.com/vi/" + videoData.video_id + "/hqdefault.jpg"; | |
GM_xmlhttpRequest({ | |
method: "GET", | |
url: "http://127.0.0.1:7777/update" + | |
"?windowTitle=" + encodeURIComponent(videoData.title) + | |
"&thumbnailURL=" + encodeURIComponent(videoThumbnail) + | |
"&videoURL=" + encodeURIComponent(videoURL) + | |
"¤tTime=" + encodeURIComponent(ytplayer.getCurrentTime()) + | |
"&duration=" + encodeURIComponent(ytplayer.getDuration()) | |
}); | |
}, 1000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment