How does the URL without the reveal parameter look like? x-devonthink-item://UUID?search=...
or x-devonthink-item://UUID&search=...
? Only the first one is valid.
Ok, so if I’m manually deleting the reveal parameter, the everything works fine.
@cgrunenberg , can you help me fix the script? I have no scripting skills.
Please post the source of your current script, there are several versions in the linked thread.
----------------------------------------------------------------------------------------------------------------------------------
-- Place on the clipboard a link to the current DT document, with the option to include either the line number or
-- the currently selected text, if any.
--
-- Original script by DT forum user dansroka and others, 2019-10
-- See https://discourse.devontechnologies.com/t/item-links-in-dt3/50513/57
--
----------------------------------------------------------------------------------------------------------------------------------
tell application id "DNtp"
try
if not (exists think window 1) then error "No window is open."
if not (exists content record) then error "Please open a document."
set this_line to the current line of current tab of think window 1
set this_page to the current page of current tab of think window 1
set find_this to the selected text of think window 1 as string
-- Create a list of options for the dialog
set options to {"Whole document"}
if this_page > -1 then copy "Page" to the beginning of the options
if this_line > 0 then copy "Line" to the beginning of the options
if not find_this = "" then copy "Selected text" to the beginning of the options
-- If more than one option, ask the user to choose
if (count of options) = 1 then
set answer to "Whole document"
else
set answer to the button returned of (display dialog "What part of the document do you want to link to?" buttons the options default button 1)
end if
set itemURL to get the reference URL of (item 1 of (selection as list)) & "?reveal=1"
if answer = "Line" then
if this_line is not "" then set itemURL to itemURL & "&line=" & this_line
else if answer = "Page" then
set itemURL to itemURL & "&page=" & this_page
else if answer = "Selected text" then
set itemURL to itemURL & "&search=" & my replaceText(find_this, " ", "%20")
else -- Fall back to "whole document"
set itemURL to itemURL & "&line=0"
end if
set the clipboard to itemURL
-- beep
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
end try
end tell
on replaceText(theString, old, new)
set {TID, text item delimiters} to {text item delimiters, old}
set theStringItems to text items of theString
set text item delimiters to new
set theString to theStringItems as text
set text item delimiters to TID
return theString
end replaceText
You could e.g. change the line
set itemURL to get the reference URL of (item 1 of (selection as list)) & "?reveal=1"
to
set itemURL to get the reference URL of (item 1 of (selection as list)) & "?reveal=0"
1 Like
Yesss
Working fine now.
Thank you, @cgrunenberg, so much. I appreciate it.
So basically, it was only to change “reveal=1” to “reveal=0”. That’s it.