Skip to content

Commit

Permalink
bookmarlet to subscribe to miniflux or inoreader
Browse files Browse the repository at this point in the history
  • Loading branch information
KTachibanaM committed Nov 10, 2024
1 parent 4be9b41 commit 8bb842d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This is a forked version of Nitter ([original version](https://github.com/sekai-
* Fix video playback via Nitter proxying
* Fix photo rail section on profile page
* Add optional Sentry error reporting
* Add bookmarklet that opens protected RSS URL from a Twitter page
* Add bookmarklet that opens protected RSS URLs from Twitter pages and subscribes them to Miniflux or Inoreader
* Unified Docker image for x86_64 and arm64

## Usage
Expand Down
5 changes: 5 additions & 0 deletions src/prefs_impl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ genPrefs:
"Reddit -> Teddit/Libreddit"
placeholder: "Teddit hostname"

"RSS readers":
minifluxHostname(input, ""):
"Subscribe to Miniflux hostname"
placeholder: "Miniflux hostname"

iterator allPrefs*(): Pref =
for k, v in prefList:
for pref in v:
Expand Down
44 changes: 44 additions & 0 deletions src/views/preferences.nim
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,32 @@ javascript:(function() {
})();
"""

let subscribeNitterRssToMinifluxJs = """
javascript:(function() {
const url = window.location.href;
if (!url.startsWith("https://x.com")) {
alert("This is not a Twitter page");
return
}
const rssUrl = `HTTP_OR_S://HOSTNAME${url.slice("https://x.com".length)}/rssRSS_KEY`;
const minifluxUrl = `https://MINIFLUX_HOSTNAME/bookmarklet?uri=${encodeURIComponent(rssUrl)}`;
window.open(minifluxUrl, '_blank').focus();
})();
"""

let subscribeNitterRssToInoreaderJs = """
javascript:(function() {
const url = window.location.href;
if (!url.startsWith("https://x.com")) {
alert("This is not a Twitter page");
return
}
const rssUrl = `HTTP_OR_S://HOSTNAME${url.slice("https://x.com".length)}/rssRSS_KEY`;
const inoreaderUrl = `https://www.inoreader.com/search/feeds/${encodeURIComponent(rssUrl)}`;
window.open(inoreaderUrl, '_blank').focus();
})();
"""

proc renderPreferences*(prefs: Prefs; path: string; themes: seq[string]; hostname: string; useHttps: bool): VNode =
buildHtml(tdiv(class="overlay-panel")):
fieldset(class="preferences"):
Expand All @@ -57,6 +83,24 @@ proc renderPreferences*(prefs: Prefs; path: string; themes: seq[string]; hostnam
legend:
text "Bookmarklets (drag them to bookmark bar)"

if prefs.minifluxHostname.len > 0:
a(href=subscribeNitterRssToMinifluxJs
.replace("MINIFLUX_HOSTNAME", prefs.minifluxHostname)
.replace("HTTP_OR_S", if useHttps: "https" else: "http")
.replace("HOSTNAME", hostname)
.replace("RSS_KEY", if existsEnv("INSTANCE_RSS_PASSWORD"): "?key=" & getEnv("INSTANCE_RSS_PASSWORD") else: "")):
text "Subscribe Nitter RSS to Miniflux"

br()

a(href=subscribeNitterRssToInoreaderJs
.replace("HTTP_OR_S", if useHttps: "https" else: "http")
.replace("HOSTNAME", hostname)
.replace("RSS_KEY", if existsEnv("INSTANCE_RSS_PASSWORD"): "?key=" & getEnv("INSTANCE_RSS_PASSWORD") else: "")):
text "Subscribe Nitter RSS to Inoreader"

br()

a(href=openNitterRssUrlJs
.replace("HTTP_OR_S", if useHttps: "https" else: "http")
.replace("HOSTNAME", hostname)
Expand Down

0 comments on commit 8bb842d

Please sign in to comment.