PDF import fails when using FireFox DT3 extension

Here’s what happens for me:

  1. In Firefox, I navigate to a web page that displays a PDF, for example, https://ocw.mit.edu/courses/mathematics/18-s097-applied-category-theory-january-iap-2019/lecture-videos-and-readings/chapter-1-generative-effects-orders-and-adjunctions/18-s097iap19ch1.pdf
  2. I click the FF DT3 extension, but nothing happens: No web clip window appears. No item is added to the DT3 DB. Nothing appears in the DT3 log. The pdf is not imported.

I have granted DT3 permission to Firefox.app in the System Preferences>Security and Privacy>Privacy Tab>Automation. DT3 is also granted Full Disk Access.

For pages other than HTML an extension like Clip to DEVONthink is not even opened as it needs injected JavaScript (like most extensions). So you cannot clip a PDF with Clip to DEVONthink in Firefox.

But you should be able to drag the PDF to the Sorter icon in the menu bar (show it from DEVONthink’s preferences).

Ah, thanks @eboehnisch! It does seem that I used it this way with DT2, but perhaps I misrember.

I did try drag and drop via the sorter, but that fails due to a permissions error. However, I have granted permissions to DT3 as shown in this snapshot.

So it may be I have something misconfigured…

There seems to be a problem with clipping from Firefox at the moment. One workaround is to use the File->Print menu then select the PDF dropdown button and choose Save PDF to DEVONthink 3.

Thanks, @aedwards. For now, I’m getting it to work properly, so long as I do not have the Sorter turned on. The FF DT3 web clip extension doesn’t seem to get on well with the Sorter, based on what I’m seeing.

Thanks for that most helpful tip. I confirm that it now works for me, too, once the Sorter is turned off.

Stephen

@Stephen_C, I’m glad that helped! :v:

Studying more closely, I find that even with Sorter turned off, the sorter window very briefly appears when I use the web clip extension. I’ll see just a flash of the sorter window, then it is replaced by the web clip window that I’m expecting.

No problems with that, but I can see these two are unexpectedly interacting.

I’ve hacked the Clip to DEVONThink extension to be able to clip any URL.

For restricted pages (e.g. about:blank, Preferences, and built-in PDF renderer) it only clips title and the URL itself. No referrer, or selection, or any other information available for regular pages is available, as far as I can tell.

It’s not much code. Here it is in its entirety.

main.js:

function clip(url, index) {
	chrome.tabs.create({url: url, active: false}, function(tab) {
		setTimeout(function(){ chrome.tabs.remove(tab.id)}, 1);
	})
}

function clipTab() {
	chrome.tabs.query(
		{active: true, currentWindow: true},
		function(tabs){
			let tab = tabs[0];
			let url =
				'x-devonthink://clip?title=' + encodeURIComponent(tab.title)
				+ '&location=' + encodeURIComponent(tab.url);
			clip(url, tab.index + 1);
		},
	)
}

var activate = function()
{
	chrome.tabs.executeScript(
		null,
		{file:"activate.js"},
		function(results){
			if (chrome.runtime.lastError || results === undefined) {
				console.log(`Error during clipping: ${chrome.runtime.lastError}`);
				console.log("Falling back to tab clipping");
				clipTab();
			}
		}
	);
}

chrome.browserAction.onClicked.addListener(function (tab)
{
	activate();
});

chrome.commands.onCommand.addListener(function(command)
{
	if (command == 'activate')
	{
		activate();
	}
});

chrome.runtime.onMessage.addListener(function (request, sender, sendResponse)
{
	if (request.action == "devonthink_activate")
	{
		activate();
	}
});

This code definitely can be improved. I tried to use Chrome-compatible API but I didn’t test it in Chrome.

I hope this will help fixing this issue in the official extension.

1 Like

Welcome @PointlessOne
Interesting. Thanks.