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
HighlanderCommentsstructure 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:
- [Wayback/Archive]
<link>: The External Resource Link element – HTML: HyperText Markup Language | MDN - [Wayback/Archive] HTML attribute:
rel– HTML: HyperText Markup Language | MDN
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
connectURLbase 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
- [Wayback/Archive] wp-og-debug/index.html at master · southp/wp-og-debug
- [Wayback/Archive] raw.githubusercontent.com/southp/wp-og-debug/master/index.html
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:
|
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
- [Wayback/Archive] mdn link rel – Google Search
- [Wayback/Archive] javascript beautifier – Google Search
- [Wayback/Archive] “highlandercomments” – Google Search
–jeroen
Gist with the JavaScript code from the first table:
- [Wayback/Archive] 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/
- [Wayback/Archive] Revisions · 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/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.getElementsByName("comment_post_ID")[0]?.value | |
| // 85080 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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/' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // {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/' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // {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/' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // {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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // {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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.title | |
| // 'Philosophy of management « The Wiert Corner – irregular stream of stuff' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.querySelector('meta[property="og:title"]')?.content | |
| // 'Philosophy of management' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.querySelector('meta[name="application-name"]')?.content | |
| // 'The Wiert Corner – irregular stream of stuff' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // {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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // {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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // {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> |
Rate this:
Share this:
- Click to share on Mastodon (Opens in new window) Mastodon
- Click to share on Bluesky (Opens in new window) Bluesky
- Share on Tumblr
- Click to share on Reddit (Opens in new window) Reddit
- Click to share on Threads (Opens in new window) Threads
- Tweet
- Click to share on Telegram (Opens in new window) Telegram
- Click to share on Nextdoor (Opens in new window) Nextdoor
- Click to share on WhatsApp (Opens in new window) WhatsApp
- Click to print (Opens in new window) Print
- Click to email a link to a friend (Opens in new window) Email
Related
This entry was posted on 2023/09/15 at 15:00 and is filed under Bookmarklet, Conference Topics, Conferences, Development, Event, HTML, JavaScript/ECMAScript, Power User, Scripting, SocialMedia, Software Development, Web Browsers, Web Development, WordPress. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
This site uses Akismet to reduce spam. Learn how your comment data is processed.






Leave a comment