-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttpcat_test.html
75 lines (69 loc) · 2.76 KB
/
httpcat_test.html
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<html>
<head>
<script>
/*
Put this part on the client:
javascript: if (document.URL.match('.*netgear.rohidekar.com.*')) { console.debug('accidental double click'); } else { window.location.href = 'http://netgear.rohidekar.com/yurl/httpcat.html?url=' + encodeURIComponent(document.URL) + '&nodeId=45' ;}
main: 45, product: 29196, video: 37658, tech: 46, other: 29172
*/
function sendUrl() {
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
if (location.href.match("youtu.*&list=.*") ) {
var newLocation=location.href.replace(/&list=[^&]+/,"");
newLocation = newLocation.replace(/.*watch/,"/watch");
window.history.pushState("object or string", "Title", newLocation);
}
var url = getParameterByName('url');
/* it seems we can't close the tab before executing the rest of the code */
document.getElementsByTagName("body")[0].innerHTML = "Saving...<br><a href='" + url + "'>" + url + "</a>";
document.body.style.backgroundColor = "#FFCC66";
var x = new XMLHttpRequest();
/* main: 45, product: 29196, video: 37658, tech: 46, other: 29172 */
x.open('GET','http://netgear.rohidekar.com:44467/?categoryId='
+ encodeURIComponent(getParameterByName('nodeId'))
+ '&value='
+ encodeURIComponent(getParameterByName('url')),true);
x.onreadystatechange =
function() {
if (x.readyState == 4) {
if (x.status == 200) {
/* window.open('', '_self', ''); */
/* window.close(); */
document.body.style.backgroundColor = "#99CC33";
document.getElementsByTagName("body")[0].innerHTML = "Success:<br><a href='" + url + "'>" + url + "</a>";
document.title = "(stashed)";
(function() {
var link = document.createElement('link');
link.type = 'image/x-icon';
link.rel = 'shortcut icon';
link.href = 'http://netgear.rohidekar.com/static/icons/tick.ico';
document.getElementsByTagName('head')[0].appendChild(link);
}());
} else {
document.body.style.backgroundColor = "#CC0033";
document.getElementsByTagName("body")[0].innerHTML = "Error:<br><a href='" + url + "'>" + url + "</a>";
// TODO: show the existing title
(function() {
var link = document.createElement('link');
link.type = 'image/x-icon';
link.rel = 'shortcut icon';
link.href = 'http://www.favicon.cc/favicon/392/638/favicon.png';
document.getElementsByTagName('head')[0].appendChild(link);
}());
alert(x.status);
}
}
};
x.send();
// window.history.pushState();
}
</script>
</head>
<body onload="sendUrl()" >
</body>
</html>