Skip to content

Instantly share code, notes, and snippets.

@jpluimers
Last active September 14, 2023 20:31
Show Gist options
  • Save jpluimers/25ccce8136776db3f65e613c56e625ad to your computer and use it in GitHub Desktop.
Save jpluimers/25ccce8136776db3f65e613c56e625ad to your computer and use it in GitHub Desktop.
Scripts for "Some JavaScript bookmarklets for WordPress published pages centered around navigation and IDs" https://wiert.me/2023/07/20/some-javascript-bookmarklets-for-wordpress-published-pages-centered-around-navigation-and-ids/
document.getElementsByName("comment_post_ID")[0]?.value
// 85080
// HighlanderComments.homeURL // as of 20230914 this does not work any more as HighlanderComments got removed
// Find this HTML element in stead and take the href:
// <link rel='openid.delegate' href='https://wiert.me/' />
document.querySelector('link[rel="openid.delegate"]').href
// 'https://wiert.me/'
// {var a=document.createElement("a"); a.setAttribute("href", HighlanderComments.connectURL); a.pathname=''; a.search=''; a.hash=''; a.href; } // as of 20230914 this does not work any more as HighlanderComments got removed
// Find the below HTML element in stead, then strip the "xmlrpc.php?rsd" from the end by removing the "pathname" and "search" bits
// <link rel="EditURI" type="application/rsd+xml" title="RSD" href="https://wiert.wordpress.com/xmlrpc.php?rsd" />
{var a=document.createElement("a"); a.setAttribute("href", document.querySelector('link[rel="EditURI"]').href); a.pathname=''; a.search=''; a.hash=''; a.href; }
// 'https://wiert.wordpress.com/'
// {var a=document.createElement("a"); a.href=HighlanderComments.connectURL; a.pathname=''; a.search=''; a.hash=''; a.href; } // as of 20230914 this does not work any more as HighlanderComments got removed
// Find the below HTML element in stead, then strip the "xmlrpc.php?rsd" from the end by removing the "pathname" and "search" bits
// <link rel="EditURI" type="application/rsd+xml" title="RSD" href="https://wiert.wordpress.com/xmlrpc.php?rsd" />
{var a=document.createElement("a"); a.href=document.querySelector('link[rel="EditURI"]').href; a.pathname=''; a.search=''; a.hash=''; a.href; }
// 'https://wiert.wordpress.com/'
// {var postID=document.getElementsByName("comment_post_ID")[0]?.value; a=document.createElement("a"); a.href=HighlanderComments.connectURL; a.pathname=''; a.search=`?p=${postID}`; a.hash=''; a.href; } // as of 20230914 this does not work any more as HighlanderComments got removed
// Find the below HTML element in stead, then strip the "xmlrpc.php?rsd" from the end by removing the "pathname" and "search" bits
// <link rel="EditURI" type="application/rsd+xml" title="RSD" href="https://wiert.wordpress.com/xmlrpc.php?rsd" />
{var postID=document.getElementsByName("comment_post_ID")[0]?.value; a=document.createElement("a"); a.href=document.querySelector('link[rel="EditURI"]').href; a.pathname=''; a.search=`?p=${postID}`; a.hash=''; a.href; }
// 'https://wiert.wordpress.com/?p=85080'
// {var postID=document.getElementsByName("comment_post_ID")[0]?.value; a=document.createElement("a"); a.href=HighlanderComments.connectURL; a.pathname='wp-admin/post.php'; a.search=`post=${postID}&action=edit&classic-editor`; a.hash=''; a.href; } // as of 20230914 this does not work any more as HighlanderComments got removed
// Find the below HTML element in stead, then strip the "xmlrpc.php?rsd" from the end by removing the "pathname" and "search" bits
// <link rel="EditURI" type="application/rsd+xml" title="RSD" href="https://wiert.wordpress.com/xmlrpc.php?rsd" />
{var postID=document.getElementsByName("comment_post_ID")[0]?.value; a=document.createElement("a"); a.href=document.querySelector('link[rel="EditURI"]').href; a.pathname='wp-admin/post.php'; a.search=`post=${postID}&action=edit&classic-editor`; a.hash=''; a.href; }
// 'https://wiert.wordpress.com/wp-admin/post.php?post=85080&action=edit&classic-editor'
document.title
// 'Philosophy of management « The Wiert Corner – irregular stream of stuff'
document.querySelector('meta[property="og:title"]')?.content
// 'Philosophy of management'
document.querySelector('meta[name="application-name"]')?.content
// 'The Wiert Corner - irregular stream of stuff'
// {var postID=document.getElementsByName("comment_post_ID")[0]?.value; a=document.createElement("a"); a.href=HighlanderComments.connectURL; a.pathname=''; a.search=`?p=${postID}`; a.hash=''; a.text=document.title; a; } // as of 20230914 this does not work any more as HighlanderComments got removed
// Find the below HTML element in stead, then strip the "xmlrpc.php?rsd" from the end by removing the "pathname" and "search" bits
// <link rel="EditURI" type="application/rsd+xml" title="RSD" href="https://wiert.wordpress.com/xmlrpc.php?rsd" />
{var postID=document.getElementsByName("comment_post_ID")[0]?.value; a=document.createElement("a"); a.href=document.querySelector('link[rel="EditURI"]').href; a.pathname=''; a.search=`?p=${postID}`; a.hash=''; a.text=document.title; a; }
// <a href="https://wiert.wordpress.com/?p=85080">Philosophy of management « The Wiert Corner – irregular stream of stuff</a>
// {var postID=document.getElementsByName("comment_post_ID")[0]?.value; a=document.createElement("a"); a.href=HighlanderComments.connectURL; a.pathname=''; a.search=`?p=${postID}`; a.hash=''; a.target="blank"; a.rel="noopener"; a.text=document.querySelector('meta[property="og:title"]')?.content; a; } // as of 20230914 this does not work any more as HighlanderComments got removed
// Find the below HTML element in stead, then strip the "xmlrpc.php?rsd" from the end by removing the "pathname" and "search" bits
// <link rel="EditURI" type="application/rsd+xml" title="RSD" href="https://wiert.wordpress.com/xmlrpc.php?rsd" />
{var postID=document.getElementsByName("comment_post_ID")[0]?.value; a=document.createElement("a"); a.href=document.querySelector('link[rel="EditURI"]').href; a.pathname=''; a.search=`?p=${postID}`; a.hash=''; a.target="blank"; a.rel="noopener"; a.text=document.querySelector('meta[property="og:title"]')?.content; a; }
// <a href="https://wiert.wordpress.com/?p=85080" target="blank" rel="noopener">The Wiert Corner - irregular stream of stuff</a>
// {var postID=document.getElementsByName("comment_post_ID")[0]?.value; a=document.createElement("a"); a.href=HighlanderComments.connectURL; a.pathname=''; a.search=`?p=${postID}`; a.hash=''; a.target="blank"; a.rel="noopener"; a.text=document.querySelector('meta[property="og:title"]')?.content; prompt("Anchor", a.outerHTML); } // as of 20230914 this does not work any more as HighlanderComments got removed
// Find the below HTML element in stead, then strip the "xmlrpc.php?rsd" from the end by removing the "pathname" and "search" bits
// <link rel="EditURI" type="application/rsd+xml" title="RSD" href="https://wiert.wordpress.com/xmlrpc.php?rsd" />
{var postID=document.getElementsByName("comment_post_ID")[0]?.value; a=document.createElement("a"); a.href=document.querySelector('link[rel="EditURI"]').href; a.pathname=''; a.search=`?p=${postID}`; a.hash=''; a.target="blank"; a.rel="noopener"; a.text=document.querySelector('meta[property="og:title"]')?.content; prompt("Anchor", a.outerHTML); }
// A popup titled “wiert.me” with a prompt named “Anchor” where you can copy this HTML from:
// <a href="https://wiert.wordpress.com/?p=85080" target="blank" rel="noopener">Philosophy of management</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment