-
Notifications
You must be signed in to change notification settings - Fork 3
/
greasemonkey.js
62 lines (58 loc) · 1.73 KB
/
greasemonkey.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// ==UserScript==
// @name KissAnime-External-Player
// @version 0.1
// @description Open KissAnime episodes in a external player
// @author Jiiks - https://github.com/Jiiks/KissAnime-External-Player
// @include http://kissanime.to/*
// @grant none
// ==/UserScript==
const playerName = "Pot Player"; //Change these to your preferred player
const playerSchema = "potplayer://"; //Change these to your preferred player
var fallBackUrl = undefined;
$(document).ready(() => {
if(document.location.search.indexOf("open=external") > -1) {
var videoUrl = getVideoUrl();
if(videoUrl != null) {
window.location = videoUrl;
window.close();
} else {
alert("Failed to locate video :(");
}
} else {
$.each($(".listing a"), function() {
var t = $(this);
var href = t.attr("href");
t.parent().append("<span> - </span>").append(`<a target="_blank" href="${href}&open=external">Play with ${playerName}</a>`)
});
$("<a/>", {
css: {
"border": "1px solid #383838",
"outline": "1px solid #000",
"background": "#303030",
"padding": "10px",
"display": "inline-block",
"margin-top": "5px",
"margin-bottom": "5px",
"cursor": "pointer"
},
text: `Play with ${playerName}`,
click: (e) => {
window.location = getVideoUrl();
setTimeout(() => {
$(".vjs-playing").click();
}, 200);
}
}).insertBefore($("#switch").parent());
fallBackUrl = getVideoUrl();
}
});
function getVideoUrl() {
var video = $("video");
if(video.length > 0) {
return `${playerSchema}${video.attr("src")}`;
}
if(fallBackUrl != undefined) {
return fallBackUrl;
}
return null;
}