-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbookmarklet.js
32 lines (27 loc) · 895 Bytes
/
bookmarklet.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
(function() {
function getLastXPath(xpexp) {
var iterator = document.evaluate(xpexp, document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
var result = iterator.iterateNext();
var lastEl = result;
while(result != null) {
result = iterator.iterateNext();
if (result == null) {
break;
}
lastEl = result;
}
return lastEl;
}
function getLastTweet() {
var author = window.location.pathname.split('/')[1];
var xp = "//a[contains(@href, '"+author+"/status') and not(contains(@href, 'photo')) and not(contains(@href, 'like')) and not(contains(@href, 'retweet'))]";
return getLastXPath(xp).pathname;
}
function queueTweet() {
/* TODO check the current URL */
var lastTweet = getLastTweet();
var url = "http://localhost:8080/thread"+lastTweet;
window.open(url, "_blank");
}
queueTweet();
})()