-
Notifications
You must be signed in to change notification settings - Fork 0
/
pr-mod.js
45 lines (38 loc) · 1.41 KB
/
pr-mod.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
// Custom function to get cookie value by name.
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
$(document).ready(function(){
$('.gh-header-actions').append('<div class="btn btn-sm btn-primary pr-mod">PR-Mod</div>');
$('.pr-mod').click(function(){
var url = window.location.href;
url = url.replace("https://github.com/","")
var server_ip = readCookie("SERVER_IP");
var server_port = readCookie("SERVER_PORT");
var server_url = "https://"+server_ip+":"+server_port+"/";
if(!server_ip || !server_port){
alert("Server credentials not set. Please open the PR-MOD extension and add server credentials.")
}
else{
var win = window.open(server_url+url);
/**
win.addEventListener("unload", function(event){
$.ajax({
type: "GET",
url: server_url+"logout",
success: function(res){
console.log(res);
}
});
});
*/
}
});
})