Fixed 'Edit Post' button
Edit Post button for BearBlog has been updated after a recent change to BearBlog partially broke it.
This version can now autodetect your username too, but if it fails, you'll still need to replace YOUR_USERNAME
Updated Code
Copy+paste this into the URL for a bookmark.
javascript:
username="YOUR_USERNAME";
use_new_tab=false;
/** gets the post's id from the analytics CSS */
function get_post_id(){
f='token: "';
m=document.querySelector("body > main").innerHTML;
id=m.substring(m.indexOf(f)+f.length);
id=id.substr(0,id.indexOf('"'));
return id;
}
if (username=="YOUR_USERNAME")username = document.querySelector('meta[content="look-for-the-bear-necessities"]').getAttribute('name');
/* gets the post id from the html markup of discoverable posts, or calls get_post_id() */
post_id = document.querySelector('[name=uid]')?.value??get_post_id();
/* Check if it's the home page */
if (window.location.pathname == '/')path = "/dashboard/";
else path = "/dashboard/posts/"+post_id+"/";
/* open the edit post page */
window.open("https://bearblog.dev/"+username+path, use_new_tab?"_blank":"_self");