neaumusic / selection-highlighter

browser highlighter for code analysis
BSD 3-Clause "New" or "Revised" License
82 stars 15 forks source link

Safari version #49

Open itaysk opened 3 years ago

itaysk commented 3 years ago

Hello, I've been enjoying this extension for a long time, thank you! I love it so much that when I decided to move to Safari, it's unavailability made me reconsider the move. I don't know if this was on your radar already but I thought I throw in my request as well, and have an issue which people can upvote.

Apple has an tool that lets you convert chrome extensions to Safari: https://bartsolutions.github.io/2020/11/20/safari-extension/ Not sure it'll flawlessly work here, but I had success with porting the other simple extensions I needed with this tool and side-loading them. Then there's the Apple Developer fee that you need to pay in order to submit :(

neaumusic commented 3 years ago

thanks man, yea I think safari is the future; hoping they get a native password manager / keychain

I know the script 'highlighter.js' was literally a copy/paste to the console in the past, but yea I never figured out the xcode process, thanks for the information

petukhov commented 2 years ago

Hi @neaumusic I managed to convert this to Safari Extension. Works fine so far. Would you be able to publish it officially in the Safari Extensions? If not, can I do it?

neaumusic commented 2 years ago

@petukhov hey sorry for the delay! yea I can definitely publish it in Safari, I think I just need to pay a fee or something

hopefully it wasn't too difficult to convert it, I've always wondered how version control should work with git, but I'll do some research

petukhov commented 2 years ago

@neaumusic No worries, yeah I think $100 fee is required. You did a great job with this extension! Looking forward to using it on Safari soon.

itaysk commented 1 year ago

So I decided to migrate to Safari after all and missed this extension too much. I am no web developer and definitely not an Apple developer but I was able to port it and I'm sharing here the steps I took:

  1. clone and build this project
  2. when building, I got an error error:0308010C:digital envelope routines::unsupported which appears to be related to older webpack version and newer node. I resolved this by adding using a legacy option: NODE_OPTIONS=--openssl-legacy-provider yarn
  3. convert the extension to Safari using Apple's conversion tool. For some reason the tool was not discovered via xcrun but running it explicitly worked: /Applications/Xcode.app/Contents/Developer/usr/bin/safari-web-extension-converter ./chrome_extension --app-name selection-highlighter --bundle-identifier itaysk.selection-highlighter --macos-only --swift --no-open --copy-resources
  4. build the bundle in Xcode (just press the play button), which will install it to Safari
  5. enable experimental support for Highlight API in Safari!! (Settings -> Feature Flags)
  6. load the extension as untrusted (Settings -> Developer -> Allow unsigned).

The only problem is the the allow untrusted checkbox is cleared after Safari is quit, I guess this is "a feature" of Safari. The solution would be to sign the extension but for this, an Apple Developer Account is needed. Anyway, hope this helps someone.

neaumusic commented 10 months ago

@itaysk I'm finally getting around to this again, with the help of Cursor AI 🙂 it even kinda works on iOS!! It's taken me so long that we can use the Highlight API version rather than the old DOM mutation version lol..

https://github.com/neaumusic/selection-highlighter/assets/3423750/94eadef1-8eb5-4d81-85f9-3e17fe8aa478

I think I've got a pretty good build process and that I can make some fixes tomorrow and publish (probably have to remove PayPal and account for no selectionstart event). It uses an intermediary build folder and shell script to convert the build folder via the CLI to the dist folder, where dist/safari_extension has the .xcodeproj, can be opened and compiled as a target for MacOS or iOS if you enable all the developer flags, sign in and sign the extension

itaysk commented 10 months ago

amazing! looking forward

neaumusic commented 10 months ago

Getting closer, primarily have to fix 'resize' triggering scrollbar redraw, but it's already come in extremely handy, can't wait to get it published

neaumusic commented 10 months ago

Just an update -- Safari on macOS and iOS seem to have a bug with the Highlight API -- img tags, the canvas, and sometimes entire paragraphs are highlighted, making it relatively useless in many cases. I'm familiar enough with Xcode now that if I can find a solution, I can definitely push them to the app stores. Might push to Testflight if I can figure that out. A bit disappointing, but they only started supporting the api in October/December 2023 so I'm not too frustrated

itaysk commented 10 months ago

yes I faced the same issue in my improvised port, but don't have the skills to workaround it. happy to help test the extension in TestFlight if you need second validation

itaysk commented 10 months ago

oh I just noticed that you included the project in the release now. I managed to install it (it complained about missing account and team, I changed "Team" to "None"), and it works fine!