Hook fails to work with Firefox- fixed in integration v. 232

Hi,

I have been using Hook for 10 months and it’s great.

While using the browsers (Firefox, Chrome, Safari), I have been able to invoke Hook and it can recognize the URL automatically and be ready for me to copy the link as markdown formatted link.

However, a few days ago, it is not working with Firefox (v 104.0.2). It said “No linkable item found found in Firefox”. It still works with Chrome (latest version) and Safari (latest version).

My Hook is using script version 230.

I tried to reboot and update Firefox, but didn’t help.

Please fix the issue, thanks!

Jake

Sorry for the trouble.

I am not able to reproduce the problem. What’s your macOS version?

Could you please copy the following script to Script Editor, run it in Script Editor and post the output here?

Summary
use scripting additions

use framework "AppKit"
-- classes, constants, and enums used
property NSShiftKeyMask : a reference to 131072
property NSAlternateKeyMask : a reference to 524288
property NSControlKeyMask : a reference to 262144
property NSEvent : a reference to current application's NSEvent

set modifier_down to true
repeat while modifier_down
	set modifier_flags to NSEvent's modifierFlags()
	set option_down to ((modifier_flags div (get NSAlternateKeyMask)) mod 2) = 1
	set shift_down to ((modifier_flags div (get NSShiftKeyMask)) mod 2) = 1
	set control_down to ((modifier_flags div (get NSControlKeyMask)) mod 2) = 1
	set modifier_down to option_down or shift_down or control_down
end repeat

tell application "Firefox"
	activate
	delay 0.05
	set myName to get name of front window
	set firefoxVer to version
	
	considering numeric strings
		set is87 to firefoxVer ≥ "87"
		set is72 to firefoxVer ≥ "72"
	end considering
	if is72 and myName ends with " - Mozilla Firefox" then
		if length of myName > 18 then
			set myName to text 1 through -19 of myName
		else
			set myName to ""
		end if
	end if
	
end tell

if is87 then
	
	try
		set theUrl to ""
		
		tell application "Firefox"
			tell application "System Events"
				if toolbar "Navigation" of first group of front window of application process "Firefox" exists then
					set theUrl to get value of UI element 1 of combo box 1 of toolbar "Navigation" of first group of front window of application process "Firefox"
				else if toolbar "导航" of first group of front window of application process "Firefox" exists then
					set theUrl to get value of UI element 1 of combo box 1 of toolbar "导航" of first group of front window of application process "Firefox"
					
				else if toolbar "Área de navegación" of first group of front window of application process "Firefox" exists then
					set theUrl to get value of UI element 1 of combo box 1 of toolbar "Área de navegación" of first group of front window of application process "Firefox"
					
				else if toolbar "Navigazione" of first group of front window of application process "Firefox" exists then
					set theUrl to get value of UI element 1 of combo box 1 of toolbar "Navigazione" of first group of front window of application process "Firefox"
					
				else if toolbar "ナビゲーション" of first group of front window of application process "Firefox" exists then
					set theUrl to get value of UI element 1 of combo box 1 of toolbar "ナビゲーション" of first group of front window of application process "Firefox"
					
				else if toolbar "導覽" of first group of front window of application process "Firefox" exists then
					set theUrl to get value of UI element 1 of combo box 1 of toolbar "導覽" of first group of front window of application process "Firefox"
					
				else if toolbar "Navegação" of first group of front window of application process "Firefox" exists then
					set theUrl to get value of UI element 1 of combo box 1 of toolbar "Navegação" of first group of front window of application process "Firefox"
					
					
				end if
				return ("[" & myName & "](" & theUrl) & ")"
				
				
			end tell
			
			
		end tell
		
		
	end try
	
end if
tell application "System Events"
	keystroke "l" using {command down}
	keystroke (key code 53)
	keystroke (key code 53)
	--keystroke "c" using {command down}
	tell process "Firefox"
		keystroke "c" using {command down}
		repeat 50 times -- poll clipboard for 5 seconds
			try
				set myText to (the clipboard)
				
				if myText is not equal to "" then
					exit repeat
				end if
			end try
			delay 0.1
		end repeat
		
	end tell
	
	set theClipboard to current application's NSPasteboard's generalPasteboard's stringForType:(current application's NSPasteboardTypeString)
	return ("[" & myName & "](" & the theClipboard as string) & ")"
end tell



Have you switched Firefox to a new language or changed the keyboard shortcuts associated with Firefox? Firefox lacks URL-automation; so Hook relies on UI scripting to control it.

Meanwhile, you can copy the link from the Firefox address bar, and use Hook’s Focus on Link in Clipboard to access Hook on any given web page.

I am using macOS Monterey, 12.4

I did not change the language of Firefox or change any keyboard shortcuts associated with Firefox.

I also tried to use Hook to get link from Firefox Developer Edition (105.0b9), and it’s not working too.

I just upgraded Firefox to 105.0. After running the script, the result was:

Hook fails to work with Firefox - Bug Reports - Hook Productivity Forum

Best,
Jake

Thanks for the extra info, @jakekei . In my tests, Hook still works well with Firefox. The following suggestions will hopefully do the trick: No Linkable Item in … – Hook.

I have the same issue as Jake, above. Hook on Mac stopped working with Firefox around a week ago, with ‘No linkable item’. Other browsers still work (I do understand that the mechanism for Firefox differs from other browsers).

Firefox 105.0, Hook 3.8 4940 v 231, MacOS 12.6, Macbook Pro 2021 M1.

Thank you for Hook, which I love, I’ve been looking forever for an app that does what Hook does!

1 Like

Could you please run the following commands on Terminal and see if it fixes the problem:
tccutil reset AppleEvents

I have the same problem with Firefox 105.0.1. A new installation of Hook (as a new user) and it does not function automatically with Firefox. Manually copying the link and ‘focus on clipboard’ and saving link… works but only gives the URL when searching it later in Hook. Tried the tccutil reset AppleEvents, for the second time gave Firefox permission, and that had no effect on fixing this fault. Safari and other apps of mine work fine. It’s just Firefox (which is my default browser).

Same problem here. FF 105.0.1, Hook 3.8, MacOS 12.6, on an M1 MB Pro.

Tried this, but alas, still no joy.
Super-duper frustrating that this Firefox problem cropped up this morning… effectively DESTROYING my daily workflow.

Same here, with exactly the same problem with PDF Expert as well.

Could you please try:

  1. tccutil reset Accessibility com.cogsciapps.hook
  2. reboot your Mac.


So annoying that it does not work with Firefox latest version. I reset accessibility again and shutdown mac and then restarted to find the same problems exist.

scratch my request for a moment.

We regret the inconvenience.

If anyone with the issue would please try using the following Firefox “get address” integration script, please let us know the result. It would involve replacing Firefox “get address” integration script in Script Editor with the following. I.e., please

  1. open Hook Preferences,
  2. choose Script Editor tab,
  3. scroll to Firefox,
  4. click on the Get Address tab, and
  5. copy paste the following into the tab, and
  6. click save.
 
use framework "AppKit"
-- classes, constants, and enums used
property NSShiftKeyMask : a reference to 131072
property NSAlternateKeyMask : a reference to 524288
property NSControlKeyMask : a reference to 262144
property NSEvent : a reference to current application's NSEvent

set modifier_down to true
repeat while modifier_down
    set modifier_flags to NSEvent's modifierFlags()
    set option_down to ((modifier_flags div (get NSAlternateKeyMask)) mod 2) = 1
    set shift_down to ((modifier_flags div (get NSShiftKeyMask)) mod 2) = 1
    set control_down to ((modifier_flags div (get NSControlKeyMask)) mod 2) = 1
    set modifier_down to option_down or shift_down or control_down
end repeat

tell application "Firefox"
    activate
    delay 0.05
    set myName to get name of front window
    if version > 72 and myName ends with " - Mozilla Firefox" then
        if length of myName > 18 then
            set myName to text 1 through -19 of myName
        else
            set myName to ""
        end if
    end if
    set firefoxVer to version
end tell

considering numeric strings
    set is87 to firefoxVer ≥ "87"
end considering

try
    set theUrl to ""
    tell application "Firefox"
        if is87 then
            tell application "System Events"
                set theUrl to get value of UI element 1 of combo box 1 of toolbar "Navigation" of first group of front window of application process "Firefox"
                return ("[" & myName & "](" & theUrl) & ")"
                
            end tell
            
        end if
        
    end tell
    
end try

tell application "System Events"
    keystroke "l" using {command down}
    keystroke (key code 53)
    keystroke (key code 53)
    --keystroke "c" using {command down}
    tell process "Firefox"
        click menu item "Copy" of menu "Edit" of menu bar 1
    end tell
    delay 0.05
    set theClipboard to current application's NSPasteboard's generalPasteboard's stringForType:(current application's NSPasteboardTypeString)
    return ("[" & myName & "](" & the theClipboard as string) & ")"
end tell

We expect to publish an auto-update integration script today (the auto-update takes effect if one does has not overridden the particular script.

thank you.

The above fix will work for vast majority of users. It basically reverts to Hook 3.7.1

We have another fix coming (probably later today, Sunday) based on the 3.8 version.
Those who override the integration script in Hook’s Script Editor (by pasting a script in the ‘get address’ tab) will not get the automatic update to this script however. (Hook respects your overrides.)

background: Something seems to have changed in Firefox which interacts with Hook 3.8 but not the 3.7.1. It’s a change in a default Firefox setting value, so it does not affect all Firefox users. I.e., users who manipulated that firefox setting may or may not have encountered the problem. Our upcoming version of the script will handle these different cases. Our Firefox integration scripts are visible to Pro users in Script Editor, so those who understand AppleScript will be able to understand the full details of the changes.

Firefox is a UI-scripted app (as marked on apps page) so the integration is a bit circuitous, and we have enhanced the integration multiple times since we released the initial integration years ago.

We have released an update on the Hook integration server with which Hook connections when you Check for App Updates and Update Scripts... (Gear Menu > Advanced; or Preferences > Updates). If Hook is configured for automatic updates you will get this automatically. In either case, no rebooting of Hook is required for integration updates.

This addresses the issue.

For users who don’t want to see the flashes of copying a ULR from the address bar(which might break their automation workflow). Here is what to do:

  1. Open Firefox
  2. Enter about:config in address bar
  3. Accept the risk (if you want to, see below) and continue
  4. Search for accessibility.force_disabled
  5. Set accessibility.force_disabled to -1

Either way, there’s a bit of a lag because Firefox lacks adequate automation (per below).

On one of our Macs, turning machineaccessibility.force_disabled machine on/off is set to -1/0. But in Firefox support page, it is 0/1.

cf:


Turning this on might have performance and security issues. Your choice.

Related:

We will publish a help page on this here https://hookproductivity.com/help/integration/using-hook-with-firefox at some point. It’s not available yet.

If Firefox were a link-friendly app, i.e., conformant with the meager requirements of the Manifesto for Ubiquitous Linking, integration would be very simple. There are plenty of browsers that do conform. Firefox does not, so we marked it as :thinking: on the linkable apps page. Having said that, I myself use Firefox for some of my browsing.

1 Like