Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves #333: Browser Extension - FinickyHelper for Chrome #332

Open
wants to merge 31 commits into
base: browser-extension
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
eb23351
MV3 Chromium Helper
torma616 Jul 25, 2024
1e8fc2e
checking for browser match and preventing unnecessary loops
torma616 Jul 26, 2024
fe8331c
Attempting Native Messaging
torma616 Jul 28, 2024
9161891
Native messaging too cumbersome, manually set browser on install
torma616 Jul 29, 2024
fb3ef71
Add shortener for MS Teams to defaultUrlShorteners
uetchy Mar 6, 2021
eab6423
Bump url-parse from 1.4.7 to 1.5.0 in /config-api
dependabot[bot] May 8, 2021
1bf0d15
Bump hosted-git-info from 2.8.8 to 2.8.9 in /config-api
dependabot[bot] May 8, 2021
1e20082
Bump ws from 7.4.2 to 7.4.6 in /config-api
dependabot[bot] May 29, 2021
52b963f
Update README.md
johnste Jul 9, 2021
f82038e
Update README.md
johnste Oct 4, 2021
11e1338
Typo fixed (paragraph 132)
kant Oct 21, 2021
1a4f0d0
enable profiles for Wavebox.io
mquinnv Oct 29, 2021
6be4ad1
doc: relocate badges and update toc
Oct 23, 2021
ad5e8b2
Update README.md
johnste Jun 7, 2022
8841dec
Remove donation section
johnste Jun 7, 2022
e4e9f90
Update FUNDING.yml
johnste Jun 7, 2022
25563ff
Update README.md
johnste Oct 10, 2022
9373abb
Add mastodon link
johnste Nov 8, 2022
1900d2b
Update README.md
johnste Jun 28, 2023
876c6cf
Add Chromium with profile support
azuenko Dec 26, 2023
affbaf8
Add JavascriptCore polyfill for require()
jamesramsay May 4, 2022
b2fab64
update credits
Jan 3, 2024
7d9cf7b
update dependencies, remove cli (unused)
Jan 8, 2024
51537d1
update node version in github workflow
Jan 8, 2024
e5dd7b4
update copyright message
Jan 8, 2024
58e7e49
Update README.md
johnste Jan 8, 2024
f05d63a
Update README.md
johnste Jan 8, 2024
0850e9c
Update LICENSE
johnste Jan 16, 2024
4b73661
safe keeping
johnste Mar 16, 2021
3ccc228
Attempting Native Messaging
torma616 Jul 28, 2024
3bcd230
Rebase
torma616 Jul 29, 2024
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
4 changes: 2 additions & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# These are supported funding model platforms

github: johnste # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
github: #johnste # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: johnste # Replace with a single Ko-fi username
ko_fi: #johnste # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
custom: # Replace with a single custom sponsorship URL
24 changes: 11 additions & 13 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,24 @@ defaults:
working-directory: ./config-api
on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x]
node-version: [20.x]


steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn --frozen-lockfile
- run: yarn build
- run: yarn test
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn --frozen-lockfile
- run: yarn build
- run: yarn test
4 changes: 4 additions & 0 deletions Finicky/Finicky.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
54E33FD71B24E27000998E13 /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54E33FD61B24E27000998E13 /* Config.swift */; };
54E4B1EB22971F7B002FA6F4 /* UpdateCheck.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54E4B1EA22971F7B002FA6F4 /* UpdateCheck.swift */; };
54FD9F562455A9A600217E30 /* Battery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54FD9F552455A9A600217E30 /* Battery.swift */; };
727EDA072C56DB86005C1A54 /* NativeHost.swift in Sources */ = {isa = PBXBuildFile; fileRef = 727EDA062C56DB86005C1A54 /* NativeHost.swift */; };
7804C1542433F40800E595D9 /* Fixtures in Resources */ = {isa = PBXBuildFile; fileRef = 7804C1532433F40700E595D9 /* Fixtures */; };
E3B53D6F253F957700F4CB19 /* defaultConfig.js in Resources */ = {isa = PBXBuildFile; fileRef = E3B53D6E253F957700F4CB19 /* defaultConfig.js */; };
E3B53D7A253F97FC00F4CB19 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3B53D72253F975700F4CB19 /* Settings.swift */; };
Expand Down Expand Up @@ -75,6 +76,7 @@
54E33FD61B24E27000998E13 /* Config.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = "<group>"; };
54E4B1EA22971F7B002FA6F4 /* UpdateCheck.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateCheck.swift; sourceTree = "<group>"; };
54FD9F552455A9A600217E30 /* Battery.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Battery.swift; sourceTree = "<group>"; };
727EDA062C56DB86005C1A54 /* NativeHost.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeHost.swift; sourceTree = "<group>"; };
7804C1532433F40700E595D9 /* Fixtures */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Fixtures; sourceTree = "<group>"; };
E3B53D6E253F957700F4CB19 /* defaultConfig.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = defaultConfig.js; sourceTree = "<group>"; };
E3B53D72253F975700F4CB19 /* Settings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -132,6 +134,7 @@
54E33FD61B24E27000998E13 /* Config.swift */,
548F11CD1B2A43F700FDDC3C /* API.swift */,
54B0E7021B4678CE003F8AEE /* ShortUrlResolver.swift */,
727EDA062C56DB86005C1A54 /* NativeHost.swift */,
5479FDD321655A3400D15A3C /* Notifications.swift */,
54B5771522860D0B0016BF77 /* Credits.rtf */,
546F1677228B487F006C5375 /* Utilities.swift */,
Expand Down Expand Up @@ -337,6 +340,7 @@
54C2F15B22BEC9BC00B3E2C3 /* Browsers.swift in Sources */,
54E33FD71B24E27000998E13 /* Config.swift in Sources */,
54FD9F562455A9A600217E30 /* Battery.swift in Sources */,
727EDA072C56DB86005C1A54 /* NativeHost.swift in Sources */,
54899CD61B20D5BC00647101 /* AppDelegate.swift in Sources */,
54B0E7031B4678CE003F8AEE /* ShortUrlResolver.swift in Sources */,
54E4B1EB22971F7B002FA6F4 /* UpdateCheck.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions Finicky/Finicky/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
}
}
}
startListening()
}

func userNotificationCenter(_: NSUserNotificationCenter, shouldPresent _: NSUserNotification) -> Bool {
Expand Down
6 changes: 5 additions & 1 deletion Finicky/Finicky/Browsers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ enum Browser: String {
case Opera = "com.operasoftware.opera"
case Vivaldi = "com.vivaldi.vivaldi"
case Safari = "com.apple.safari"
case Wavebox = "com.bookry.wavebox"
case Chromium = "org.chromium.chromium"
}

public func getBrowserCommand(_ browserOpts: BrowserOpts, url: URL) -> [String] {
Expand Down Expand Up @@ -103,7 +105,9 @@ private func getProfileOption(bundleId: String, profile: String) -> [String]? {
Browser.Chrome.rawValue,
Browser.Edge.rawValue,
Browser.EdgeBeta.rawValue,
Browser.Vivaldi.rawValue:
Browser.Vivaldi.rawValue,
Browser.Wavebox.rawValue,
Browser.Chromium.rawValue:
return ["--profile-directory=\(profile)"]

// Blisk and Opera doesn't support multiple profiles even though they are Chromium based
Expand Down
16 changes: 16 additions & 0 deletions Finicky/Finicky/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -382,5 +382,21 @@ open class FinickyConfig {
FinickyAPI.setContext(ctx)
ctx.setObject(FinickyAPI.self, forKeyedSubscript: "finickyInternalAPI" as NSCopying & NSObjectProtocol)
ctx.evaluateScript("var finicky = finickyConfigApi.createAPI();")

// Add polyfills
let require: @convention(block) (String) -> (JSValue?) = { path in
let expandedPath = NSString(string: path).expandingTildeInPath

// Return void or throw an error here.
guard FileManager.default.fileExists(atPath: expandedPath)
else { debugPrint("Require: filename \(expandedPath) does not exist")
return nil }

guard let fileContent = try? String(contentsOfFile: expandedPath)
else { return nil }

return self.ctx.evaluateScript(fileContent)
}
ctx.setObject(require, forKeyedSubscript: "require" as NSString)
}
}
9 changes: 3 additions & 6 deletions Finicky/Finicky/Credits.rtf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{\rtf1\ansi\ansicpg1252\cocoartf2512
{\rtf1\ansi\ansicpg1252\cocoartf2757
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 Menlo-Regular;}
{\colortbl;\red255\green255\blue255;\red0\green0\blue0;\red255\green255\blue255;}
{\*\expandedcolortbl;;\cssrgb\c0\c1\c1;\cssrgb\c100000\c100000\c99985\c0;}
Expand All @@ -9,8 +9,5 @@
\f0\fs24 \cf2 \cb3 Homepage: \
{\field{\*\fldinst{HYPERLINK "https://github.com/johnste/finicky"}}{\fldrslt https://github.com/johnste/finicky}}\
\
Questions? Ask me on twitter: \
{\field{\*\fldinst{HYPERLINK "https://twitter.com/johnste_"}}{\fldrslt https://twitter.com/johnste_}}\
\
Want to support development?\
{\field{\*\fldinst{HYPERLINK "https://ko-fi.com/johnste"}}{\fldrslt https://ko-fi.com/johnste}}}
Questions? Ask me: \
{\field{\*\fldinst{HYPERLINK "mailto:john@johnste.se"}}{\fldrslt john@johnste.se}}}
4 changes: 2 additions & 2 deletions Finicky/Finicky/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>311</string>
<string>319</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>LSUIElement</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2020 John Sterling</string>
<string>Copyright © 2024 John Sterling</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
Expand Down
33 changes: 33 additions & 0 deletions Finicky/Finicky/NativeHost.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// NativeHost.swift
// Finicky
//
// Created by Alex Torma on 7/28/24.
// Copyright © 2024 Alex Torma. All rights reserved.
//

import Foundation

func startListening() {
// Function to read a message from stdin
func readMessage() -> String? {
let input = FileHandle.standardInput
let data = input.availableData
return String(data: data, encoding: .utf8)
}

// Function to write a message to stdout
func writeMessage(_ message: String) {
if let data = message.data(using: .utf8) {
FileHandle.standardOutput.write(data)
}
}

while true {
if let message = readMessage() {
// Process the message
let response = "{\"text\": \"Received: \(message)\"}"
writeMessage(response)
}
}
}
1 change: 1 addition & 0 deletions Finicky/Finicky/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ let defaultUrlShorteners = [
"t.co",
"tiny.cc",
"tinyurl.com",
"urlshortener.teams.microsoft.com",
]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015-2019 John Sterling
Copyright (c) 2015-2024 John Sterling

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
/>
</h1>

<strong>Always open the right browser</strong>
<strong>🇺🇦 Always open the right browser 🇺🇦</strong><br>
[![GitHub start](https://badgen.net/github/stars/johnste/finicky?color=pink&icon=github)](https://github.com/johnste/finicky/)
[![GitHub release](https://badgen.net/github/release/johnste/finicky/stable?color=purple)](https://github.com/johnste/finicky/releases/)

</div>

Expand All @@ -17,10 +19,6 @@ Finicky is a macOS application that allows you to set up rules that decide which
- Edit urls before opening them
- Complete control over configuration using JavaScript

[![GitHub start](https://badgen.net/github/stars/johnste/finicky?color=pink&icon=github)](https://github.com/johnste/finicky/)
[![GitHub release](https://badgen.net/github/release/johnste/finicky/stable?color=purple)](https://github.com/johnste/finicky/releases/)




<div align="center">
Expand All @@ -35,13 +33,11 @@ Finicky is a macOS application that allows you to set up rules that decide which

- [Installation](#installation)
- [Example configuration](#example-configuration)
- [Basic configuration](#basic-configuration)
- [Rewrite urls](#rewrite-urls)
- [Documentation](#documentation)
- [Configuration tips](#configuration-tips)
- [Alternatives](#alternatives)
- [Building Finicky from source](#building-finicky-from-source)
- [Support development](#support-development)
- [Current status of Finicky development](#current-status-of-finicky-development)
- [Issues](#issues)
- [Bugs](#bugs)
- [Feature Requests](#feature-requests)
Expand Down Expand Up @@ -81,8 +77,8 @@ module.exports = {
],
handlers: [
{
// Open apple.com and example.org urls in Safari
match: ["apple.com/*", "example.org/*"],
// Open apple.com and example.com urls in Safari
match: finicky.matchHostnames(["apple.com", "example.com"]),
browser: "Safari"
},
{
Expand Down Expand Up @@ -128,11 +124,15 @@ make
make run
```

## Support development
## Current status of Finicky development

I don't have time to work on Finicky actively, and that has been the case for several years. I still use it every day and it works really well for my use cases. When I have time I try to respond to support requests on twitter and github.

Don't expect any work on features, new releases, or even bug fixes on my part at this point. Unless things change a lot in my personal or professional life I won't have time to work on Finicky for the forseeable future.

If you want to help support further development of finicky, feel free to buy me a coffee on ko-fi.
### Looking for co-maintainers

<a href='https://ko-fi.com/E1E5W973' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi1.png?v=2' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
Do you want to help out with the development of Finicky? My time to spend to work on Finicky is very limited, and my limited experience with Swift and MacOS I feel is holding it back. If you are experienced in Swift and MacOS development and this sounds interesting to you please reach out to me, preferably on [Twitter](https://twitter.com/johnste_).

## Issues

Expand All @@ -151,7 +151,7 @@ a 👍.

### Questions

Have any other questions or need help? Please feel free to reach out to me on [Twitter](https://twitter.com/johnste_).
Have any other questions or need help? Please feel free to reach out to me on [Mastodon](https://mastodon.se/@john) or [Twitter](https://twitter.com/johnste_).

## License

Expand Down
95 changes: 95 additions & 0 deletions browser-extension/FinickyHelper.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*!
* File: FinickyHelper.css
* Description: Popup CSS. Redirects http(s):// to finicky(s):// for specific URLs
* Author: Alex Torma (https://github.com/torma616/)
* Date: July 24, 2024
* Copyright: ©2024 Alex Torma
* License: MIT
* Version: 1
*
*/
body {
width: max-content;
margin: auto;
text-align: center;
font-size: 10px;
max-width: 550px;
background-color: #aaa;
}

input {
font-size: 10px;
}

#popup,
h2 {
margin: 5px;
}

h3,
p {
margin: 0;
}

#options-wrapper {
display: flex;
flex-direction: column;
align-items: center;
width: 100%
}

#patterns-wrapper,
#prefixes-wrapper {
width: 100%;
}

.patterns,
.browsers,
#prefixes {
display: flex;
flex-wrap: wrap;
gap: 5px;
justify-content: center;
}

.browsers {
margin: 0.5rem 0 0 0;
width: 100%;
}

[class*=-patterns] {
align-items: center;
display: flex;
flex-direction: column;
}

.patterns,
#prefixes {
width: 98%;
margin: 0.5rem 0 1rem 0;
}

.pattern,
.prefix {
display: inline-flex;
flex-direction: column;
}

.pattern {
flex: 0 0 170px;
}

.prefix {
flex: 0 0 180px;
}

.browsers .pattern {
width: 100%;
flex-grow: 1;
}

#current-browser input,
.browsers input {
font-weight: bold;
text-align: center;
}
Loading