Removing parts of youtube notification link name and address

On YouTube there is a notifications list for new videos from subscribed channels (the bell symbol on the upper right). If you bookmark a link from this list with the right-click popup menu item “Bookmark This Link”, the name and address that are stored look something like this:

I would like an addon that removes some parts from this information before it is stored as a bookmark.

Most importantly, I would like the &pp=… part to be removed from the end of the link. This is something youtube has recently added and is problematic because when you click on the bookmark the address starts out looking like that but, after a short delay, the &pp=… part disappears and then the link no longer matches the stored bookmark, which means that you can’t remove the bookmark by clicking the star in the address bar (“edit this bookmark”).

Second most important to me is to remove the “1 hour ago” (or “27 minutes ago” or whatever) from the end of the link name since this has no meaning when stored as a bookmark.

Thirdly I would like the word “uploaded” to be removed from the name. (Why not?)

I don’t know if anyone has programmed an extension like this, but it should be possible with bookmarks.onCreated, bookmarks.update() and a regular expression.

Thank’s for your reply. :cowboy_hat_face:
I do some programming so I will look into bookmarks.onCreated, etc., and see what I can do. I’ll post back with my attempt and/or questions in a bit.

This seems to be a solution.

manifest.json

{
  "manifest_version": 2,
  "name": "YouTube Bookmark Fix",
  "version": "1.1",
  "description": "Remove certain info from youtube notification bookmarks.",

  "permissions": [
    "bookmarks"
  ],

  "background": {
    "scripts": ["background.js"]
  }
}

background.js

function modifyBookmark(id, bm) {
    let title = bm.title.replace(/ \d+ \S+ ago$/, '');
    if (bm.title != title) {
        bm.title = title.replace(" uploaded:", ":");
        bm.url = bm.url.replace(/&pp=.{12}/, '');
        browser.bookmarks.update(id, {title:bm.title, url:bm.url});
    }
}

browser.bookmarks.onCreated.addListener(modifyBookmark);

I decided, at least for now, to detect a youtube notification bookmark by the “2 days ago”, “1 hour ago”, “27 minutes ago” ending of the title. I could also check for “youtube.com” in the link.