-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgreaselog.js
More file actions
29 lines (27 loc) · 862 Bytes
/
Copy pathgreaselog.js
File metadata and controls
29 lines (27 loc) · 862 Bytes
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
// ==UserScript==
// @name Log
// @namespace http://www.amotlpaa.org/gmscripts
// @description Post titles and URLs to a local logging server on request.
// @include *
// @grant GM_registerMenuCommand
// @grant GM_xmlhttpRequest
// ==/UserScript==
function alertFail(resp) {
alert("Error! " + resp.status + " " + resp.statusText
+ "\n" + resp.responseText);
}
GM_registerMenuCommand(
"Log this page",
function () {
GM_xmlhttpRequest({
method: "POST",
url: "http://localhost:3042/",
data: "* [" + (content.document.title || content.document.location)
+ "](" + content.document.location + ")\r\n",
onerror: alertFail,
onload: function (resp) {
if (resp.status!="200") alertFail(resp);
}
})
},
"l")