Lyrics & Knowledge Personal Pages Record Shop Auction Links Radio & Media Kids Membership Help
The Mudcat Cafesj



User Name Thread Name Subject Posted
GUEST,Grishka Tech: how do i? (blue clicky) (45) RE: Tech: how do i? (blue clicky) 28 May 25


Here is my bold attempt at a linkifyer to single Mudcat posts. Unfortunately, you first have to save the page to your computer, then copy the "Date:" line of the post you want to link to. The usage will be self-explanatory.

Note: courtesy of ChatGPT; my own part being reduced to fault-finding. Feel free to improve.


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Extract Post Link</title>
</head>
<body>
    <label for="dateInput">Enter the "Date:" line of the post:</label>
    <input type="text" id="dateInput"><br><br>

    <p>On the thread page in your browser, right click and invoke the "Save page as ..." function. Remember where you stored the file, and press the following button to select it.</p>
    <input type="file" id="fileInput"><br><br>

    <p id="output"></p>

    <script>
       document.getElementById("fileInput").addEventListener("change", function() {
            let dateInput = document.getElementById("dateInput").value.trim();
            if (!dateInput.startsWith("Date:")) {
                document.getElementById("output").textContent = "Error: Please enter the entire 'Date:' line.";
                return;
            }

            const file = this.files[0];
            if (!file) {
                document.getElementById("output").textContent = "Error: Please select a file.";
                return;
            }

            const reader = new FileReader();
            reader.onload = function(event) {
                const text = event.target.result;

                // Modify search string: "Date: mydate" -> "Date:</b> mydate"
                dateInput = dateInput.replace("Date:", "Date:</b>");

                // Search for modified date string
                const dateIndex = text.indexOf(dateInput);
                if (dateIndex === -1) {
                   document.getElementById("output").textContent = "Error: Date text not found in file.";
                   return;
                }

                // Extract canonical URL
                const canonicalMatch = text.match(/<link rel="canonical" href="([^"]+)">/);
                const url = canonicalMatch ? canonicalMatch[1] : null;

                // Find the **last anchor before the date**
                const beforeText = text.substring(0, dateIndex);
                const anchorMatch = [...beforeText.matchAll(/<a name="?([^">]+)"?>/gi)].pop();
                const anchor = anchorMatch ? anchorMatch[1] : null;

                if (!url || !anchor) {
                   document.getElementById("output").textContent = "Error: Could not extract required data.";
                   return;
                }

                // Construct final link
                const resultLink       = `<a href="${url}#${anchor}">this postt</a>`;
                const resultLinkEsc = `&lt;a href="${url}#${anchor}"&gt;this post&lt;/a&gt;`;
                document.getElementById("output").innerHTML = "The following link has been copied to your clipboard:<br>"
                      + resultLinkEsc
                      + "<br>Just press Ctrl.-v in your post to Mudcat, or anywhere where links are allowed. Edit the \"this post\" part to your wishes."

                // Copy to clipboard
                navigator.clipboard.writeText(resultLink).catch(err => console.error("Clipboard error:", err));
            };

            reader.readAsText(file);
       });
    </script>
</body>
</html>


Post to this Thread -

Back to the Main Forum Page

By clicking on the User Name, you will requery the forum for that user. You will see everything that he or she has posted with that Mudcat name.

By clicking on the Thread Name, you will be sent to the Forum on that thread as if you selected it from the main Mudcat Forum page.

By clicking on the Subject, you will also go to the thread as if you selected it from the original Forum page, but also go directly to that particular message.

By clicking on the Date (Posted), you will dig out every message posted that day.

Try it all, you will see.