Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Added setting to show/hide post and comment scores
- Added setting to show/hide bot content
- Added the ability to render SVGs in markdown bodies - contribution from @micahmo
- Added Safari extension to open Lemmy links in Thunder

### Fixed
- Fixed issue where custom tabs would not respect default browser when opening links
Expand Down
13 changes: 13 additions & 0 deletions ios/Open In Thunder/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.Safari.web-extension</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).SafariWebExtensionHandler</string>
</dict>
</dict>
</plist>
11 changes: 11 additions & 0 deletions ios/Open In Thunder/Resources/_locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extension_name": {
"message": "Open In Thunder",
"description": "The display name for the extension."
},
"extension_description": {
"message": "Opens Lemmy links in Thunder",
"description": "Description of what the extension does."
}
}

100 changes: 100 additions & 0 deletions ios/Open In Thunder/Resources/content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
let instances = [
"aussie.zone",
"bakchodi.org",
"beehaw.org",
"burggit.moe",
"dataterm.digital",
"delraymisfitsboard.com",
"discuss.tchncs.de",
"exploding-heads.com",
"feddit.ch",
"feddit.cl",
"feddit.de",
"feddit.dk",
"feddit.it",
"feddit.nl",
"feddit.nu",
"feddit.uk",
"geddit.social",
"hexbear.net",
"infosec.pub",
"iusearchlinux.fyi",
"jlai.lu",
"lemdro.id",
"lemm.ee",
"lemmings.world",
"lemmus.org",
"lemmy.blahaj.zone",
"lemmy.ca",
"lemmy.dbzer0.com",
"lemmy.eco.br",
"lemmy.fmhy.ml",
"lemmy.kya.moe",
"lemmy.ml",
"lemmy.nz",
"lemmy.one",
"lemmy.sdf.org",
"lemmy.today",
"lemmy.world",
"lemmy.zip",
"lemmygrad.ml",
"lemmynsfw.com",
"mander.xyz",
"midwest.social",
"monero.town",
"monyet.cc",
"pawb.social",
"programming.dev",
"reddthat.com",
"sh.itjust.works",
"slrpnk.net",
"social.fossware.space",
"sopuli.xyz",
"startrek.website",
"szmer.info",
"ttrpg.network",
"vlemmy.net",
"waveform.social",
"www.hexbear.net",
"yiffit.net",
];

const observeUrlChange = () => {
let oldHref = document.location.href;

const body = document.querySelector("body");
const observer = new MutationObserver((mutations) => {
if (oldHref !== document.location.href) {
oldHref = document.location.href;
openInThunder();
}
});

observer.observe(body, { childList: true, subtree: true });
};


function isLemmyInstance(arr) {
const currentHost = new URL(document.location.href).host;

for (let i = 0; i < instances.length; i++) {
if (currentHost.includes(instances[i])) {
return true;
}
}

return false;
}

function openInThunder() {
const shouldOpen = isLemmyInstance();
if (!shouldOpen) return;

let url = new URL(document.location.href);
url.protocol = "thunder:";
window.location.href = url;
}

openInThunder();
window.onload = observeUrlChange;

Binary file added ios/Open In Thunder/Resources/images/icon-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Open In Thunder/Resources/images/icon-256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Open In Thunder/Resources/images/icon-48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Open In Thunder/Resources/images/icon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Open In Thunder/Resources/images/icon-64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Open In Thunder/Resources/images/icon-96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 95 additions & 0 deletions ios/Open In Thunder/Resources/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"manifest_version": 3,
"default_locale": "en",

"name": "__MSG_extension_name__",
"description": "__MSG_extension_description__",
"version": "1.0",

"icons": {
"48": "images/icon-48.png",
"96": "images/icon-96.png",
"128": "images/icon-128.png",
"256": "images/icon-256.png",
"512": "images/icon-512.png"
},

"content_scripts": [{
"js": [ "content.js" ],
"matches": [
"*://aussie.zone/*",
"*://bakchodi.org/*",
"*://beehaw.org/*",
"*://burggit.moe/*",
"*://dataterm.digital/*",
"*://delraymisfitsboard.com/*",
"*://discuss.tchncs.de/*",
"*://exploding-heads.com/*",
"*://feddit.ch/*",
"*://feddit.cl/*",
"*://feddit.de/*",
"*://feddit.dk/*",
"*://feddit.it/*",
"*://feddit.nl/*",
"*://feddit.nu/*",
"*://feddit.uk/*",
"*://geddit.social/*",
"*://hexbear.net/*",
"*://infosec.pub/*",
"*://iusearchlinux.fyi/*",
"*://jlai.lu/*",
"*://lemdro.id/*",
"*://lemm.ee/*",
"*://lemmings.world/*",
"*://lemmus.org/*",
"*://lemmy.blahaj.zone/*",
"*://lemmy.ca/*",
"*://lemmy.dbzer0.com/*",
"*://lemmy.eco.br/*",
"*://lemmy.fmhy.ml/*",
"*://lemmy.kya.moe/*",
"*://lemmy.ml/*",
"*://lemmy.nz/*",
"*://lemmy.one/*",
"*://lemmy.sdf.org/*",
"*://lemmy.today/*",
"*://lemmy.world/*",
"*://lemmy.zip/*",
"*://lemmygrad.ml/*",
"*://lemmynsfw.com/*",
"*://mander.xyz/*",
"*://midwest.social/*",
"*://monero.town/*",
"*://monyet.cc/*",
"*://pawb.social/*",
"*://programming.dev/*",
"*://reddthat.com/*",
"*://sh.itjust.works/*",
"*://slrpnk.net/*",
"*://social.fossware.space/*",
"*://sopuli.xyz/*",
"*://startrek.website/*",
"*://szmer.info/*",
"*://ttrpg.network/*",
"*://vlemmy.net/*",
"*://waveform.social/*",
"*://www.hexbear.net/*",
"*://yiffit.net/*"
]
}],

"action": {
"default_popup": "popup.html",
"default_icon": {
"16": "images/toolbar-icon-16.png",
"19": "images/toolbar-icon-19.png",
"32": "images/toolbar-icon-32.png",
"38": "images/toolbar-icon-38.png",
"48": "images/toolbar-icon-48.png",
"72": "images/toolbar-icon-72.png"
}
},

"permissions": [ ]
}

14 changes: 14 additions & 0 deletions ios/Open In Thunder/Resources/popup.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
:root {
color-scheme: light dark;
}

body {
padding: 8px;
font-family: system-ui;
text-align: left;
}

@media (prefers-color-scheme: dark) {
/* Dark Mode styles go here. */
}

13 changes: 13 additions & 0 deletions ios/Open In Thunder/Resources/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="popup.css" />
</head>
<body>
<strong>Thunder</strong>
<p>Thunder is a fully open source, cross-platform, community-driven project available on GitHub. Fully free of advertisements and trackers.</p>
<p>This extension allows opening Lemmy links in Thunder</p>
</body>
</html>

18 changes: 18 additions & 0 deletions ios/Open In Thunder/SafariWebExtensionHandler.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import SafariServices
import os.log

class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling {

func beginRequest(with context: NSExtensionContext) {
let item = context.inputItems[0] as! NSExtensionItem
let message = item.userInfo?[SFExtensionMessageKey]
os_log(.default, "Received message from browser.runtime.sendNativeMessage: %@", message as! CVarArg)

let response = NSExtensionItem()
response.userInfo = [ SFExtensionMessageKey: [ "Response to": message ] ]

context.completeRequest(returningItems: [response], completionHandler: nil)
}

}

Loading