Giter VIP home page Giter VIP logo

Comments (14)

johnlindquist avatar johnlindquist commented on August 16, 2024 1

🤔 I'll have to see if it's possible to query for the default browser

from kit.

johnlindquist avatar johnlindquist commented on August 16, 2024 1

@KiwiKilian @timsun28

I want to move away from AppleScript as much as possible. So my gameplan is to write a Chrome, Firefox, etc extension that can offer a bridge between Script Kit. A quick start would be something as simple as:

"An extension that writes the current open tabs to a tabs.json"

Then Script Kit could read that file and we're back in business.

Any chance that's something you'd be interested in building?

Note: We've already started work on a Script Kit VS Code extension that follows the same "bridge" idea: https://marketplace.visualstudio.com/items?itemName=johnlindquist.kit-extension

from kit.

timsun28 avatar timsun28 commented on August 16, 2024 1

@johnlindquist

That sounds interesting, and would also help with using the same extension for both windows, mac and possibly linux.

Have you already planned out how you're going to trigger this write to a file functionality (for a browser/vscode)?
If Firefox doesn't have AppleScript support, how are you planning to trigger something within an extension?

I would be interested to look into this, I'll give it a go this week and see what I can come up with for Firefox in particular.

from kit.

timsun28 avatar timsun28 commented on August 16, 2024 1

@johnlindquist I've found that browser add-ons allow an extension to communicate between native apps using standard input/output on the app side of things to receive messages. I think this could be used to let script kit the app send a message to the browser extension for data and let the browser extension reply with the requested data. The only downside is that there seems to be quite a lot of differences between browsers and operating systems. But they are all well documented, so it shouldn't be too much of a problem.

Some pages that contain information about this protocol:
General info
App side of things
Example using a python app
My example GitHub repo for ScriptKit

Could you let me know if you think this is a good approach for the given problem and if the Node.js example is something that could be implemented in ScriptKit app?

The only thing I don't quite get is how the .json file works in the native app. It doesn't seem to need to be registered in a way.

from kit.

johnlindquist avatar johnlindquist commented on August 16, 2024

On my phone, but I believe it's:

await getTabs("Brave")

It defaults to Chrome.

from kit.

ValentinH avatar ValentinH commented on August 16, 2024

You are completely right, I thought it was defaulting to the default browser of the system.

from kit.

valeriashpiner avatar valeriashpiner commented on August 16, 2024

@johnlindquist I am having the same error, when I pass anything as a parameter, but not "Google Chrome".
I get: SyntaxError: Unexpected end of JSON input

For example:


let tabs = await getTabs("Firefox")

let tabsMd = tabs
  .map(tab => `* [${tab.title || tab.url}](${tab.url})`)
  .join("\n")

let notes = await editor(tabsMd)

...more code

from kit.

KiwiKilian avatar KiwiKilian commented on August 16, 2024

I'm experiencing the same. Basically I'm trying to port this script to use Firefox Developer Edition.

For the line:

let currentTabs = await getTabs("Firefox Developer Edition")

It throws:

[warn] SyntaxError: Unexpected end of JSON input

I also tried with "Firefox", no luck either. In both cases, the browser will start if not already started. Might this be due to missing privacy automation allowances? Kit only lists "Google Chrome" there to check.

from kit.

timsun28 avatar timsun28 commented on August 16, 2024

I'm having the same issues as @KiwiKilian when I try to get the current tabs from a Firefox window. I have done some research and testing and found the following two sources that caught my attention:

https://bugzilla.mozilla.org/show_bug.cgi?id=125419
A 21-year-old bug report on Firefox to add basic AppleScript functionality. Apparently it hasn't been implemented and that's why it's not supported in Script Kit.

https://matthewbilyeu.com/blog/2018-08-24/getting-url-and-tab-title-from-firefox-with-applescript
This is a blog post from someone who wrote an AppleScript to get the current tab title and url through copy/paste. This is probably not a good use case for a getTabs function that needs to get all open tabs from all windows, but is interesting to read about.

I guess the only thing we can do is wait and let the Firefox developers know that we would like AppleScript support in a future version. And for script kit to maybe add a warning/message that not all browser functions are compatible with Firefox.

from kit.

johnlindquist avatar johnlindquist commented on August 16, 2024

@timsun28 So my hope is that extensions have events when tabs/urls change.

So the full functionality of the extension would be:

when tabs change -> write tabs.json

Then Script Kit would only have to read the tabs.json file and wouldn't have to know anything about Firefox/Applescript/etc.

from kit.

johnlindquist avatar johnlindquist commented on August 16, 2024

@timsun28 It's also possible that Firefox creates a file/db somewhere on the system already. Chrome does this for bookmarks/history:

#1041

But I haven't looked into Firefox at all

from kit.

johnlindquist avatar johnlindquist commented on August 16, 2024

@timsun28 Wow, that could unlock a ton of cool stuff and definitely worth exploring 🤔

I still think the first step is to simply capture the current state (windows/tabs/urls) into a json file that a script could read.

Script Kit could even watch the json file for changes if you want to run a script any time the browser state changes.

To me, "browser state as a json file" just feels like a cross-platform, easy win that covers 90% of scenarios.

Then we could dive into sending messages between browser<->Script Kit and build out some really exciting workflows 🤯

from kit.

timsun28 avatar timsun28 commented on August 16, 2024

@johnlindquist Looking at the following page it seems like there is not really a good solution for writing to any file type. The only option I see is to write to the IndexedDB of the browser, but I'm not sure if IndexedDB is available outside the app to other native applications.

And because Script Kit won't be directly communicating with the browser, you need to make sure that the .json file is always up-to-date.

The JSON solution also doesn't allow for any future changes in terms of actions in the browser like switch to active tab, favourite a certain tab, delete history or any other actions that could be triggered from an extension.

I will try to make a proof of concept that works with script kit and Firefox, so I could demonstrate how this could be further implemented in the app!

from kit.

johnlindquist avatar johnlindquist commented on August 16, 2024

@timsun28 gotcha, guess my assumptions we're way off. 🙃

When you next post, can you start a new discussion in the "Ideas" category titled "Firefox Extension" or something. Just want this to be easier to find for everyone :)

from kit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.