Browse Source

fix issues with bookmarklet

master
Wesley Kerfoot 4 years ago
parent
commit
e752bdf6a3
  1. 3
      bookmarklet.js
  2. 2
      bookmarklet.min.js
  3. 2
      tweetlog.nimble

3
bookmarklet.js

@ -16,13 +16,12 @@
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'))]";
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 */
/* TODO check the last tweet URL is valid, skip likes/images */
var lastTweet = getLastTweet();
var url = "http://localhost:8080/thread"+lastTweet;
window.open(url, "_blank");

2
bookmarklet.min.js

@ -1 +1 @@
javascript:k="http://localhost:8080/thread"+b(),window.open(k,"_blank");function b(){return function(t){for(var n=document.evaluate(t,document,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),a=n.iterateNext(),e=a;null!=a&&null!=(a=n.iterateNext());)e=a;return e}("//a[contains(@href, '"+window.location.pathname.split("/")[1]+"/status') and not(contains(@href, 'photo')) and not(contains(@href, 'like'))]").pathname}var k;
javascript:(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(){var lastTweet=getLastTweet();var url="http://localhost:8080/thread"+lastTweet;window.open(url,"_blank")}queueTweet()})();

2
tweetlog.nimble

@ -15,4 +15,4 @@ requires "https://github.com/pragmagic/karax"
task bookmark, "Builds the minified bookmarklet":
"echo -n 'javascript:' > ./bookmarklet.min.js".exec
"uglifyjs --mangle --compress toplevel,sequences=false bookmarklet.js >> ./bookmarklet.min.js".exec
"uglifyjs bookmarklet.js >> ./bookmarklet.min.js".exec

Loading…
Cancel
Save