From e752bdf6a39955f8e62acd6d83e10388cb30de18 Mon Sep 17 00:00:00 2001 From: Wesley Kerfoot Date: Mon, 10 Feb 2020 02:28:47 -0500 Subject: [PATCH] fix issues with bookmarklet --- bookmarklet.js | 3 +-- bookmarklet.min.js | 2 +- tweetlog.nimble | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bookmarklet.js b/bookmarklet.js index 4b34de1..ef33b61 100644 --- a/bookmarklet.js +++ b/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"); diff --git a/bookmarklet.min.js b/bookmarklet.min.js index 5307ef0..4c26d2a 100644 --- a/bookmarklet.min.js +++ b/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()})(); diff --git a/tweetlog.nimble b/tweetlog.nimble index 1e656ae..e37d905 100644 --- a/tweetlog.nimble +++ b/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