BearBlog: Edit the post you are currently viewing
Create a bookmark in your browser with the name "Edit Post" and url set to the old or new javascript code.
OLD CODE
replace {YOUR_USER_NAME}
javascript:window.open("https://bearblog.dev/{YOUR_USER_NAME}/dashboard/posts/"+document.querySelector('[name=uid]').value+"/", "_self")
If you're on your bearblog dashboard, you'll see your username in the URL.
NEW CODE
The old code didn't let you edit pages that had make_discoverable:false
in the header.
Replace "YOUR_USERNAME" with yours. Mine's 'reedybear' like my subdomain.
javascript:username="YOUR_USERNAME";function get_post_id(){f='border-image: url("/hit/';h=document.head.innerHTML;id=h.substring(h.indexOf(f)+f.length);id=id.substr(0,id.indexOf('/'));return id;}window.open("https://bearblog.dev/"+username+"/dashboard/posts/"+(document.querySelector('[name=uid]')?.value??get_post_id())+"/", "_self");
Old Code Explanation
javascript: // Tells the bookmark to run javascript
window.open( // open a url
"https://bearblog.dev/{YOUR_USER_NAME}/dashboard/posts/"
+ document.querySelector('[name=uid]') // select a hiddden element on the page
.value // get your unique id from the element (it's part of the URL)
+"/", // Ends the URL that is being opened
"_self" // Tells the browser to open the url in the current tab. Use "_blank" for new tab
)
New Code Explanation
Discoverable pages have a uid printed as a value on an HTML Node. non-discoverable pages only print the uid in some CSS as part of the analytics for Bear. So I have to find that CSS code block & cut the uid of the post out of it. I define a function get_post_id()
that gets this uid out of the CSS code & returns it. I still look for that html node with the uid
, and then call get_post_id()
if that node doesn't exist.
I'm not doing a line-by-line breakdown, though.