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 comment
  • 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 comment
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 comment
  • 5 months later...
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 comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...