You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Name: Finicky Switch Default Browser// Description: Switches the default browser in Finicky config// Author: Strajkimport'@johnlindquist/kit'importfsfrom'fs'letfinickyPath=home('.finicky.js')// Check if Finicky config existsif(!fs.existsSync(finickyPath)){awaitdiv({html: ` <div class="p-4 bg-red-100 text-red-800"> <h3 class="font-bold">Finicky not installed</h3> <p>Or at least, ~/.finicky.js was not found</p> <p>Please install Finicky first: <code>brew install finicky</code></p> </div> `})exit()}// Resolve symlink if finickyPath is a symlink, e.g. /Users/strajk/.finicky.js -> /Users/strajk/Projects/setup/home/.finicky.jsfinickyPath=fs.realpathSync(finickyPath)// List of possible browsers to select fromconstpossibleBrowsers=['Google Chrome','Google Chrome Dev','Firefox','Firefox Developer Edition','Safari','Opera','Brave','Microsoft Edge','Browserosaurus',]try{// Read the content of the Finicky configuration fileconstconfigContent=awaitreadFile(finickyPath,'utf8')// Log number of lines in config fileconstnumLines=configContent.split('\n').lengthconsole.log('==='+newDate().toISOString())console.log(`Config file has ${numLines} lines`)// Regular expression to find the default browser setting in the configconstdefaultBrowserRegex=/defaultBrowser:"([^"]*?)".?/constmatch=defaultBrowserRegex.exec(configContent)constcurrentDefaultBrowser=match ? match[1] : nullif(!currentDefaultBrowser){console.log('No default browser found')exit()}// Prompt the user to select a new default browserconstselectedBrowser=awaitarg({placeholder: 'Select a default browser',choices: possibleBrowsers,hint: 'Current default browser: '+currentDefaultBrowser,})// Create a new comment based on the previously selected browserconstnewComment=currentDefaultBrowser ? ` Previously: ${currentDefaultBrowser}` : ''// Replace the old default browser setting with the new one, including the updated commentconstnewConfigContent=configContent.replace(defaultBrowserRegex,`defaultBrowser: "${selectedBrowser}", //${newComment}`)// Write the updated content back to the Finicky configuration fileawaitwriteFile(finickyPath,newConfigContent)// Display a notification to confirm the updateawaitnotify({title: 'Finicky Config Updated',body: `Default browser set to ${selectedBrowser}`,})}catch(error){// Handle errors, such as the config file not existingconsole.error(`Failed to update Finicky config: ${error}`)awaitnotify({title: 'Finicky Config Update Failed',body: `Error: ${error}`,})}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Screenshot-2025-02-22T17.25.41.mp4
Open finicky-default-browser in Script Kit
Beta Was this translation helpful? Give feedback.
All reactions