From b7969d172ce8af7a14d3831afce17d536d8e68c5 Mon Sep 17 00:00:00 2001 From: FrenchHope Date: Fri, 14 Jul 2017 17:34:31 +0200 Subject: [PATCH] Manages Firefox reader mode In Reader mode Firefox has a special syntax for the URL of the current page. The URL is encoded and begins with "about:reader?url=" which can't be added to scuttle of course. --- background.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/background.js b/background.js index c81506d..b24ce94 100644 --- a/background.js +++ b/background.js @@ -13,8 +13,16 @@ function shareURL(){ gettingHeight.then(onGotHeight, onError); var tab = tabs[0]; - - var url = instance + "/bookmarks.php?action=add&address=" + encodeURIComponent(tab.url) + "&title=" + tabs[0].title; + + // manages Mozilla Firefox reader mode + var rawUrl = tab.url; + var partToRemove = partToRemove = "about:reader?url="; + if(rawUrl.includes(partToRemove)) { + rawUrl = rawUrl.substring(partToRemove.length); + rawUrl = decodeURIComponent(rawUrl); + } + + var url = instance + "/bookmarks.php?action=add&address=" + encodeURIComponent(rawUrl) + "&title=" + tabs[0].title; widthInt = Number(windowWidth); heightInt = Number(windowHeight);