The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Revision of some JavaScript bookmarklets for WordPress published pages centered around navigation and IDs: WordPress ditched the undocumented HighlanderComments structure

Posted by jpluimers on 2023/09/15

As promised yesterday, I updated the scripts for Some JavaScript bookmarklets for WordPress published pages centered around navigation and IDs

Code (which broke at 20230914 because of WordPress.com changes: the undocumented HighlanderComments structure got removed; I will update the gist later on and post an updated blog post)

Instead of the undocumented HighlanderComments structure, I now use two (also undocumented) link rel elements.

In addition, I found this element that will be interesting in the future: <link rel='shortlink' href='https://wp.me/pvelJ-m8g' />.

You can view the change with the below archivals of the Wayback Machine and Archive.is.

And of course I learned a few things from these MDN entries:

The 20230530 archivals (Wayback/Archive) of wiert.me/2022/02/14/philosophy-of-management have this HighlanderComments structure:

  • Normal
    var HighlanderComments = {"loggingInText":"Logging In\u2026","submittingText":"Posting Comment\u2026","postCommentText":"Post Comment","connectingToText":"Connecting to %s","commentingAsText":"%1$s: You are commenting using your %2$s account.","logoutText":"Log Out","loginText":"Log In","connectURL":"https:\/\/wiert.wordpress.com\/public.api\/connect\/?action=request&domain=wiert.me","logoutURL":"https:\/\/wiert.wordpress.com\/wp-login.php?action=logout&_wpnonce=ec2705fbf5","homeURL":"https:\/\/wiert.me\/","postID":"85080","gravDefault":"identicon","enterACommentError":"Please enter a comment","enterEmailError":"Please enter your email address here","invalidEmailError":"Invalid email address","enterAuthorError":"Please enter your name here","gravatarFromEmail":"This picture will show whenever you leave a comment. Click to customize it.","logInToExternalAccount":"Log in to use details from one of these accounts.","change":"Change","changeAccount":"Change Account","comment_registration":"","userIsLoggedIn":"","isJetpack":"","text_direction":"ltr"};
  • Beautified through [Wayback/Archive] Online JavaScript beautifier:
    var HighlanderComments = {
        "loggingInText": "Logging In\u2026",
        "submittingText": "Posting Comment\u2026",
        "postCommentText": "Post Comment",
        "connectingToText": "Connecting to %s",
        "commentingAsText": "%1$s: You are commenting using your %2$s account.",
        "logoutText": "Log Out",
        "loginText": "Log In",
        "connectURL": "https:\/\/wiert.wordpress.com\/public.api\/connect\/?action=request&domain=wiert.me",
        "logoutURL": "https:\/\/wiert.wordpress.com\/wp-login.php?action=logout&_wpnonce=ec2705fbf5",
        "homeURL": "https:\/\/wiert.me\/",
        "postID": "85080",
        "gravDefault": "identicon",
        "enterACommentError": "Please enter a comment",
        "enterEmailError": "Please enter your email address here",
        "invalidEmailError": "Invalid email address",
        "enterAuthorError": "Please enter your name here",
        "gravatarFromEmail": "This picture will show whenever you leave a comment. Click to customize it.",
        "logInToExternalAccount": "Log in to use details from one of these accounts.",
        "change": "Change",
        "changeAccount": "Change Account",
        "comment_registration": "",
        "userIsLoggedIn": "",
        "isJetpack": "",
        "text_direction": "ltr"
    };

The 20230914 archivals ([Wayback/Archive]) of wiert.me/2022/02/14/philosophy-of-management have these link rel elements that can be used to obtain some of the information previously obtained from the HighlanderComments structure:

  • Getting the above connectURL base domain:
    <link rel="EditURI" type="application/rsd+xml" title="RSD" href="https://wiert.wordpress.com/xmlrpc.php?rsd" />
  • Getting the actual domain:
    <link rel='openid.delegate' href='https://wiert.me/' />

Other resource showing the HighlanderComments structure

Updated JavaScript code

This results in these new (and much larger) JavaScript bits as compared to the previous blog entry:

What How Example output
post ID document.getElementsByName("comment_post_ID")[0]?.value 85080
custom domain URL document.querySelector('link[rel="openid.delegate"]').href 'https://wiert.me/'
original domain URL {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/'
original domain URL {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/'
canonical URL on original domain {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'
classic editor URL {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'
full post title (including blog title) document.title 'Philosophy of management « The Wiert Corner – irregular stream of stuff'
post title only document.querySelector('meta[property="og:title"]')?.content 'Philosophy of management'
blog title only document.querySelector('meta[name="application-name"]')?.content 'The Wiert Corner - irregular stream of stuff'
anchor HTML to canonical URL on original domain with full post title {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>
anchor HTML to canonical URL on original domain with full post title {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>​
popup with anchor HTML to canonical URL on original domain with full post title {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>

Updated Bookmarklets

  • Editing a post:

    javascript:{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=''; location=a.href; }

  • Getting a post anchor:
    javascript:{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); }

Queries

–jeroen


Gist with the JavaScript code from the first table:


document.getElementsByName("comment_post_ID")[0]?.value
// 85080

view raw

01.post-ID.js

hosted with ❤ by GitHub


// 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/&#39; />
document.querySelector('link[rel="openid.delegate"]').href
// 'https://wiert.me/&#39;


// {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&quot; />
{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/&#39;


// {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&quot; />
{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/&#39;


// {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&quot; />
{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&#39;


// {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&quot; />
{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&#39;


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&quot; />
{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&quot; />
{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&quot; 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&quot; />
{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&quot; target="blank" rel="noopener">Philosophy of management</a>

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.