Jump to content

Safirechrome


Recommended Posts

  • 2 months later...
  • 2 weeks later...

Safirechrome provides the ability to open an URL from current browser window in Safari, Chrome,Firefox or Opera. Only installed browsers will be listed as target browser. 

 
Update v 1.2: 
  1. Opera added
  2. Only installed browsers will be listed
  3. Ability to type and search for a target browser
Link to post
  • 4 weeks later...
  • 3 years later...

I'm trying to edit it so it just goes back and forth between safari and chrome - no stop in an Alfred window looking for a return along the way.

 

Sadly I've got it down to 1 choice, but it still needs a return.

set query to "{query}" set xml to "<?xml version=\"1.0\"?><items>" set browsers to {"Google Chrome"}
set browsersID to {"com.google.Chrome"} set listCount to 0 repeat with browser in browsers     set listCount to listCount + 1     set browserID to item listCount of browsersID    
    if checkApp(browserID) and (query is equal to "" or browser contains query) then         set xml to xml & "<item arg=\"" & browserID & "\" valid=\"yes\">
<title>" & browser & "</title>
<subtitle>Open URL in " & browser & "</subtitle>
<icon>" & browser & ".png</icon></item>"     end if end repeat set xml to xml & "</items>" return xml
on checkApp(theBundleId)         try         tell application "Finder" to get application file id theBundleId         return true     on error         return false     end try end checkApp

 

Link to post
2 hours ago, Cameron B said:

I want it to work like firechrome, but for Chrome and Safari.

 

Then you're going about it the wrong way. You need a Run Script element instead of a Script Filter. If there's a Script Filter, Alfred will always appear.

 

If you create your Hotkey with these settings:

image.png.0141cf0a89c5e4c7e9f7e7d6fa8ba06e.png

 

You can use this script in a Run Script action with Language = /usr/bin/osascript (JS):

ObjC.import('stdlib');

const browser = $.getenv('focusedapp'),
  safariId = 'com.apple.Safari',
  chromeId = 'com.google.Chrome';

console.log(`active app = ${browser}`);

var chrome = Application(chromeId),
  safari = Application(safariId);

chrome.includeStandardAdditions = true;
safari.includeStandardAdditions = true;

function run() {
  switch(browser) {
    case safariId:
      var url = safari.documents[0].url();
      chrome.openLocation(url);
      chrome.activate();
      break;
    case chromeId:
      var url = chrome.windows[0].activeTab.url();
      safari.openLocation(url);
      safari.activate();
      break;
    default:
      throw(new Error(`unsupported browser: ${browser}`));
  }
}

 

Edited by deanishe
Link to post
  • 5 months later...
27 minutes ago, friedmilk said:

Is there any way to get this to work with Brave?

 

If you mean the script I posted, change the line chromeId = 'com.google.Chrome'; to chromeId = 'com.brave.Browser';

Link to post
18 hours ago, deanishe said:

 

If you mean the script I posted, change the line chromeId = 'com.google.Chrome'; to chromeId = 'com.brave.Browser';

 

I'm thinking about the original workflow. Do you know what I'd have to change to achieve that?

Edited by friedmilk
Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...