Using a script to extract tagged blocks and assign them as new notes in specific folders based on the tag

What I’m trying to do

Hey all, just started using Obsidian this past month. I’ve adopted some of what Eleanor Konik does in using a user script to extract highlights from a source article note and making them their own individual notes that are sent to another folder.

I would like to do this in a modified way though for some specific articles. If I’m reading articles tagged with the document reference “swn” for example, and i’m making highlights that I individually tag with #character, #plot, #location, or #group, I would like the script to extract those into individual notes and send them to specific folders based on the tag (e.g. #plot goes to the plot folder).

I’m attaching below screenshot to give you an example of what the highlights in the source note would look like, and how I would want them to be extracted into their own individual new notes in other folders.

Things I have tried

The closest help article I could find in the forum is this one, Funnel all headings blocks with specific tags into a new note, but here the advice basically goes down the route of using headings and dataviews to pull info together instead of creating new notes based on the tag attached to a highlight.

I’ve tried modifying the user script a bit, but I’m not sure how to tell it to look for the tag attached to the highlight and then select the correct folder to send it to.

I hope I explained all that clearly… let me know if anything is confusing, and I totally appreciate any thoughts or ideas anyone might have. Thanks!