Skip to main content
The Institute for Niftiness and Flexibility

Grist For the Mill

I sprang ahead, so this is tomorrows entry already.

Need to get back onto Grist at some point. But I have more I want to do with Eleventy first.


Rude awakening last night that after soloing 250 hero points on my badly geared Firebrand with a build I haven't figured out yet, I need to advance the story in Secrets of the Obscure before I can try the dual-pistol build GuildJen is soloing legendary's with.

https://guildjen.com/willbender-open-world-build/


Instead of doing what I intended to do this afternoon, I spent the last few hours dinking around with Gemini and Claude seeing if I could get any useful work out of them.

The impetus was I wanted to copy a link so I could add it to a certain MeFi discussion, and wondered if either tool would create the HTML for me in a repeatable way. The answer was no. Claude isn't hooked up to the Internet, and Gemini gives up on any page that so much as presents a "Sign Up For Our Newsletter" pop-up.

Between the two of them, I got this far. Neither one would format the date the way I wanted or could refactor pubDate so it wasn't doing the same thing in three different places. It also does some dumb-assery to get the text onto the clipboard, but I am out of patience for today.

It did make me laugh when I had to teach Claude what, "Uff da. Negatronic, Ghostrider," meant and that it agreed with me that maybe it would be easier to use the Mark I Eyeball to find dates on web pages.


// This script extracts citation information from a webpage and copies it to the clipboard in my idiosyncratic format.

javascript:(function() {
  // Get the title, author, and site name from meta tags
  var title = document.querySelector('meta[property="og:title"]') ? document.querySelector('meta[property="og:title"]').getAttribute('content') : document.title;
  var author = document.querySelector('meta[name="author"]') ? document.querySelector('meta[name="author"]').getAttribute('content') : '';
  var siteName = document.querySelector('meta[property="og:site_name"]') ? document.querySelector('meta[property="og:site_name"]').getAttribute('content') : (document.domain.includes('www.') ? document.domain.replace('www.', '') : document.domain);

  // Try to get publish date from various meta tags
  var pubDate = '';
  var dateMetaTags = ['article:published_time', 'og:published_time', 'article:modified_time', 'dc.date.issued'];
  for (var i = 0; i < dateMetaTags.length; i++) {
    var metaTag = document.querySelector('meta[property="' + dateMetaTags[i] + '"]');
    if (metaTag) {
      pubDate = new Date(metaTag.getAttribute('content')).toLocaleDateString('en-GB', { day: 'numeric', month: 'long', year: 'numeric' });
      break;
    }
  }

  // If no publish date found in meta tags, try to extract from content
  if (!pubDate) {
    var content = document.querySelector('body').textContent;
    var regex = /((0[1-9]|[12]\d|3[01])[- \/.](0[1-9]|1[012])[- \/.](\d{4}))/;
    var matches = regex.exec(content);
    if (matches != null) {
      pubDate = new Date(matches[0]).toLocaleDateString('en-GB', { day: 'numeric', month: 'long', year: 'numeric' });
    } else {
      pubDate = new Date().toLocaleDateString('en-GB', { day: 'numeric', month: 'long', year: 'numeric' });
    }
  }

  // Construct the citation format in APA style
  var url = window.location.href;
  var format = '<a href="' + url + '">“' + title + '</a>,” ' + author + '. ';
  if (siteName && pubDate) {
    format += '(' + siteName + ', ' + pubDate + ').';
  } else if (siteName) {
    format += '(' + siteName + ').';
  } else if (pubDate) {
    format += '(' + pubDate + ').';
  }

  // Copy the citation format to clipboard
  var tempInput = document.createElement('textarea');
  tempInput.value = format;
  document.body.appendChild(tempInput);
  tempInput.select();
  document.execCommand('copy');
  document.body.removeChild(tempInput);

  // Alert user that citation has been copied
  alert('Citation copied to clipboard: ' + format);
})();

Although I'm just noticing that it looks like it munged the quote marks in the above. Fabulous.

Without comments and on one line for pasting into bookmark URL fields.

javascript:(function(){ var title = document.querySelector('meta[property="og:title"]') ? document.querySelector('meta[property="og:title"]').getAttribute('content') : document.title; var author = document.querySelector('meta[name="author"]') ? document.querySelector('meta[name="author"]').getAttribute('content') : ''; var siteName = document.querySelector('meta[property="og:site_name"]') ? document.querySelector('meta[property="og:site_name"]').getAttribute('content') : (document.domain.includes('www.') ? document.domain.replace('www.', '') : document.domain); var pubDate = ''; var dateMetaTags = ['article:published_time', 'og:published_time', 'article:modified_time', 'dc.date.issued']; for (var i = 0; i < dateMetaTags.length; i++) {   var metaTag = document.querySelector('meta[property="' + dateMetaTags[i] + '"]');   if (metaTag) { pubDate = new Date(metaTag.getAttribute('content')).toLocaleDateString('en-GB', {day: 'numeric', month: 'long', year: 'numeric'}); break;   } } if (!pubDate) {   var content = document.querySelector('body').textContent;   var regex = /((0[1-9]|[12]\d|3[01])[- \/.](0[1-9]|1[012])[- \/.](\d{4}))/;   var matches = regex.exec(content);   if (matches != null) { pubDate = new Date(matches[0]).toLocaleDateString('en-GB', {day: 'numeric', month: 'long', year: 'numeric'});   } else { pubDate = new Date().toLocaleDateString('en-GB', {day: 'numeric', month: 'long', year: 'numeric'});   } } var url = window.location.href; var format = '<a href="' + url + '">“' + title + ',”</a> ' + author + ', '; if (siteName && pubDate) {   format += '<i>' + siteName + '</i>, ' + pubDate; } else if (siteName) {   format += '<i>' + siteName + '</i>'; } else if (pubDate) {   format += pubDate; } var tempInput = document.createElement('textarea'); tempInput.value = format; document.body.appendChild(tempInput); tempInput.select(); document.execCommand('copy'); document.body.removeChild(tempInput); alert('Citation copied to clipboard: ' + format); })();

These aren't really included because I think anyone will find them useful. They're mostly for my own reference and edification. Still, y'know, use at your own risk. Your milage may vary. No warranty expressed or implied. Not available in every state; Sorry, Tennessee.