Skip to content

Instantly share code, notes, and snippets.

@jsmm
jsmm / obsidian-web-clipper.js
Last active September 17, 2021 07:50 — forked from kepano/obsidian-web-clipper.js
Obsidian Bookmarklet to clip pages
javascript: Promise.all([import('https://unpkg.com/turndown@6.0.0?module'), import('https://unpkg.com/@tehshrike/readability@0.2.0'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
tell application id "com.devon-technologies.thinkpro2"
set these_items to the selection
if these_items is {} then error "Please select some contents."
repeat with this_item in these_items
set RecordLink to the reference URL of this_item
set DevonThinkLink to RecordLink & "?page=0"
set PdfPath to get the path of this_item
set PdfName to the name of this_item
--2011-06-10
--http://organognosi.blogspot.com/
tell application "Skim"
set the clipboard to ""
set numberOfPages to count pages of document 1
activate
set myColorCodes to my chooseColor()
display dialog "Do you want to export all the notes or some of them?" buttons {"All", "Some"} default button 1
set answer to button returned of the result
--2011-04-02
--http://organognosi.blogspot.com
tell application "Skim"
display dialog "Give the written page number:" default answer "" buttons {"Cancel", "OK"} default button 2
set writtenNumber to text returned of the result as integer
set numberNote5 to (get text for note 5 of page 1 of document 1)
set numberInThePDF to writtenNumber - numberNote5
go document 1 to page numberInThePDF of document 1
The AppleScript code is the following:
--2011-03-25
--http://organognosi.blogspot.com
tell application id "com.devon-technologies.thinkpro2"
set these_items to the selection
if these_items is {} then error "Please select some contents."
repeat with this_item in these_items
(**
--You need to adjust appropriately the name of the DEVONthink database in the line:
tell database "MySources"
**)
tell application "Skim"
set the xDEVONthinkLink to (get text for note 4 of document 1) as string
set customUUID to text 21 thru -8 of xDEVONthinkLink as string
end tell
tell application "Skim"
set FilePath to get the file of front document
tell application "Finder"
activate
reveal FilePath
end tell
end tell
javascript:(function(){clip%20=%20window.getSelection();%20url%20=%20location.href;%20var%20currentdate%20=%20new%20Date();%20var%20weekdayNames%20=%20new%20Array("Sunday",%20"Monday",%20"Tuesday",%20"Wednesday",%20"Thursday",%20"Friday",%20"Sat");%20var%20weekday%20=%20weekdayNames[currentdate.getDay()];%20var%20brackets%20=%20"[[";%20%20var%20myDate%20=%20new%20Date();%20%20var%20year%20=%20myDate.getFullYear();%20var%20month%20=%20myDate.getMonth();%20if(month%20<=%209)%20%20%20%20%20month%20=%20'0'+month;%20var%20day=%20myDate.getDate();%20if(day%20<=%209)%20%20%20%20%20day%20=%20'0'+day;%20var%20prettyDate%20=%20year%20+'-'+%20month%20+'-'+%20day;%20var%20minutes%20=%20myDate.getMinutes();%20if(minutes%20<=%209)%20minutes%20=%20'0'%20+%20minutes;%20%20%20var%20hours%20=%20myDate.getHours();%20if(hours%20<=%209)%20hours%20=%20'0'%20+%20hours;%20%20%20theFinalString%20=%20clip%20+%20"%20("%20+%20url%20+%20"%20-%20"%20+%20brackets%20+%20prettyDate%20+%20"]]%20"%20+%20weekday%20+%20",%20"%20+%20hours%20+%20"