Skip to content

Instantly share code, notes, and snippets.

@Ptujec
Last active February 23, 2023 18:50
Show Gist options
  • Save Ptujec/dfa41cd0515f24796ccc57965720e232 to your computer and use it in GitHub Desktop.
Save Ptujec/dfa41cd0515f24796ccc57965720e232 to your computer and use it in GitHub Desktop.
I tried my hand on a LB action to show, open and remove items from Safaris Reading List. Show and open them is not a problem. I also managed to remove items from the plist (row 61-65). It works temporarily. But something is missing.
// LaunchBar Action Script
function run() {
var plist = File.readPlist('~/Library/Safari/Bookmarks.plist')
var listItems = plist.Children[3].Children
var result = []
for (var i = 0; i < listItems.length; i++) {
var preview = listItems[i].ReadingList.PreviewText
var title = listItems[i].URIDictionary.title
var link = listItems[i].URLString
result.push({
title: title,
subtitle: preview,
icon: 'eyeglassesTemplate',
action: 'options',
actionArgument: {
id: i,
title: title,
link: link,
plist: plist
}
})
}
return result
}
function options(params) {
return [
{
title: 'Open ' + params.title,
url: params.link,
icon: 'openTemplate'
},
{
title: 'Remove ' + params.title,
icon: 'removeTemplate',
action: 'removeItem',
actionArgument: {
id: params.id,
plist: params.plist
}
}
]
}
function removeItem(params) {
// var newWebBookmarkUUID = LaunchBar.execute('/usr/bin/uuidgen').trim()
// var plist = params.plist
// var webBookmarkUUID = plist.WebBookmarkUUID
// var i = params.id
// var listItems = params.plist.Children[3].Children
// listItems.splice(i, 1)
// var plist = params.plist
// File.writePlist(plist, '~/Desktop/testPlist.plist')
// Does work only until sync kicks in. There are some parameters that need to be updated (WebBookmarkUUID, CloudKitDeviceIdentifier) … but I don't know how
// Tried creating a new UUID … but that's not solving it
// File.writePlist(plist, '~/Library/Safari/Bookmarks.plist')
}
@Ptujec
Copy link
Author

Ptujec commented Dec 11, 2021

When iCloud syncs the next time the deleted items reappear. I also tried changing the WebBookmarkUUID (manually as of now).
It probably shows that I am not a developer. Can someone help? Or is that impossible with this approach?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment