Update Chrome Bookmark

Is there a way to update a Chrome bookmark quicker/more elegantly than a few mouse clicks and paste action? (The URL references a number that goes up 1 each day). Some of you guys are absolute wizards (from my remedial point of view) with under-the-hood stuff like this, and I'm always interested in learning more and making things as simple as possible.

Hey @jsmith85,

This should be doable, but I'd have to know the folder/bookmark hierarchy.

-Chris

It's clickable right from the Bookmarks Bar

Okay, that's easy. It takes just a little AppleScript:

tell application "Google Chrome"
   set theBookmark to bookmark item "Google" of bookmarks bar
   set URL of theBookmark to "https://www.google.com/"
end tell

Run from an Execute an AppleScript action.

What does the URL numbering scheme look like?

It shouldn't be too hard to calculate and assemble the new URL.

-Chris

The URL looks like: http://www.URL.com/forums/showthread.php?tid=1234&action=lastpost.

1234 is the number that increases by 1 each day. I think I've figured out everything but how to insert the updated URL into the AppleScript, though I'm betting there's a solution just outside my knowledge box...

Something like this should work.

AppleScript Code
----------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2018/12/15 20:34
# dMod: 2018/12/15 20:34 
# Appl: Google Chrome
# Task: Increment a URL ID Number in Chrome's Bookmarks
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @ASObjC, @Google_Chrome, @Increment, @URL, @ID, @Number @Bookmarks
----------------------------------------------------------------
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
----------------------------------------------------------------

tell application "Google Chrome"
   set theBookmark to bookmark item "Google" of bookmarks bar
   set theURL to URL of theBookmark
end tell

# Remove all non-digit characters to isolate the ID number.
set urlIdNum to ((its cngStr:"[^\\d]" intoString:"" inString:theURL) + 1) as text

# Replace the ID number with the incremented ID number.
set newURL to its cngStr:"\\d+" intoString:urlIdNum inString:theURL

tell application "Google Chrome" to set URL of theBookmark to newURL

----------------------------------------------------------------
--» HANDLERS
----------------------------------------------------------------
on cngStr:findString intoString:replaceString inString:dataString
   set anNSString to current application's NSString's stringWithString:dataString
   set dataString to (anNSString's stringByReplacingOccurrencesOfString:findString withString:replaceString ¬
      options:(current application's NSRegularExpressionSearch) range:{0, length of dataString}) as text
end cngStr:intoString:inString:
----------------------------------------------------------------

Run using an Execute an AppleScript action.

-Chris