When you run the script, it will show a textarea with the markdown code for crediting sources. I use it to save time when posting to Lemmy.

Usual disclaimer: I’ve tested it but only to a certain point (with my environment). If you find any issue you don’t know how to fix, let me know.

EDIT: Here are the scripts in pastebin raw text (lemmy currently replaces the ampersand signs with & and it breaks the scripts:


Tip (for firefox users): you can set a keyword for a bookmarklet that you can run form the navbar. Once you get used to “Control+L (focus navbar) > keyword” it becomes really frictionless.


For generic pages, the output is:

Source: [Page title](page_url)

For Tumblr posts the outuput is:

Source: [Page title](page_url)

Tumblr archive: https://site_url/archive

RSS Feed: https://site_url/rss

For ArtStation pages the outuput is:

Source: [Page title](page_url)

> Description (if there is any)

ArtStation profile: https://profile_url

RSS Feed: https://profile_url.rss

pretty printed code
(function() {
    var sourceCode = "";
    var isArtStation = document.location.host.endsWith("artstation.com");
    if (isArtStation) {
        sourceCode = getArtstationInfo();
    } else {
        var title = ("%s" || document.title).replace("[", "\\[").replace("]", "\\]");
        sourceCode = `Source: [${title}](${document.location.href})`;
        var isTumblr = [...document.querySelectorAll("link")].filter(e => e.href && e.href.indexOf("tumblr.com") >= 0).length > 0;
        if (isTumblr) {
            var tumblrUrl = `${document.location.protocol}//${document.location.host}`;
            sourceCode += "\r\n\r\nTumblr archive: " + tumblrUrl + "/archive";
            sourceCode += "\r\n\r\nRSS Feed: " + tumblrUrl + "/rss";
        }
    }
    var inpt = document.getElementById("crul-source-code");
    if (!inpt) {
        inpt = document.createElement("textarea");
        inpt.id = "crul-source-code";
        inpt.style.position = "fixed";
        inpt.style.color = "black";
        inpt.style.top = "5vh";
        inpt.style.left = "5vw";
        inpt.style.height = "90vh";
        inpt.style.width = "45vw";
        inpt.style.border = "solid 2px tomato";
        inpt.style.zIndex = "99999";
        document.body.appendChild(inpt);
        var closeBtn = document.createElement("button");
        closeBtn.onclick = () => {
            inpt.remove();
            closeBtn.remove();
        };
        closeBtn.innerHTML = "X";
        closeBtn.style.position = "fixed";
        closeBtn.style.width = "30px";
        closeBtn.style.height = "30px";
        closeBtn.style.background = "tomato";
        closeBtn.style.color = "white";
        closeBtn.style.border = "none";
        closeBtn.style.zIndex = "999999";
        closeBtn.style.top = "5vh";
        closeBtn.style.left = "calc(50vw - 30px)";
        document.body.appendChild(closeBtn);
    };
    inpt.value = sourceCode;
    inpt.focus();
    inpt.select();

    function getArtstationInfo() {
        var sourceCode = "";
        var title = document.querySelector(".project-description-title");
        if (!title) return;
        var author = document.querySelector(".project-author-name h3 a");
        if (!author) return;
        title = title.innerText.replace("[", "\\[").replace("]", "\\]");
        sourceCode = `Source: [${title} (by ${author.innerText} - ArtStation)](${document.location.href})`;
        var description = document.querySelector(".project-description p:first-child");
        if (description && description.innerText) {
            description = description.innerText.replaceAll("\n", "  \n> ");
            sourceCode += ` \r\n\r\n> ${description}`;
        }
        var profileUrl = document.querySelector(".project-author-name a").href;
        sourceCode += "\r\n\r\nArtStation profile: " + profileUrl;
        sourceCode += "\r\n\r\nRSS Feed: " + profileUrl + ".rss";
        return sourceCode;
    }
})();

One-liner:

javascript:(function() {var sourceCode = "";var isArtStation = document.location.host.endsWith("artstation.com");if (isArtStation) {sourceCode = getArtstationInfo();} else {var title = ("%s" || document.title).replace("[", "\\[").replace("]", "\\]");sourceCode = `Source: [${title}](${document.location.href})`;var isTumblr = [...document.querySelectorAll("link")].filter(e => e.href && e.href.indexOf("tumblr.com") >= 0).length > 0;if (isTumblr) {var tumblrUrl = `${document.location.protocol}//${document.location.host}`;sourceCode += "\r\n\r\nTumblr archive: " + tumblrUrl + "/archive";sourceCode += "\r\n\r\nRSS Feed: " + tumblrUrl + "/rss";}}var inpt = document.getElementById("crul-source-code");if (!inpt) {inpt = document.createElement("textarea");inpt.id = "crul-source-code";inpt.style.position = "fixed";inpt.style.color = "black";inpt.style.top = "5vh";inpt.style.left = "5vw";inpt.style.height = "90vh";inpt.style.width = "45vw";inpt.style.border = "solid 2px tomato";inpt.style.zIndex = "99999";document.body.appendChild(inpt);var closeBtn = document.createElement("button");closeBtn.onclick = () => {inpt.remove();closeBtn.remove();};closeBtn.innerHTML = "X";closeBtn.style.position = "fixed";closeBtn.style.width = "30px";closeBtn.style.height = "30px";closeBtn.style.background = "tomato";closeBtn.style.color = "white";closeBtn.style.border = "none";closeBtn.style.zIndex = "999999";closeBtn.style.top = "5vh";closeBtn.style.left = "calc(50vw - 30px)";document.body.appendChild(closeBtn);};inpt.value = sourceCode;inpt.focus();inpt.select();function getArtstationInfo() {var sourceCode = "";var title = document.querySelector(".project-description-title");if (!title) return;var author = document.querySelector(".project-author-name h3 a");if (!author) return;title = title.innerText.replace("[", "\\[").replace("]", "\\]");sourceCode = `Source: [${title} (by ${author.innerText} - ArtStation)](${document.location.href})`;var description = document.querySelector(".project-description p:first-child");if (description && description.innerText) {description = description.innerText.replaceAll("\n", "  \n> ");sourceCode += ` \r\n\r\n> ${description}`;}var profileUrl = document.querySelector(".project-author-name a").href;sourceCode += "\r\n\r\nArtStation profile: " + profileUrl;sourceCode += "\r\n\r\nRSS Feed: " + profileUrl + ".rss";return sourceCode;}})();
  • Crul@lemm.eeOP
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    1 year ago

    lemmy 0.18.4 currently incorrectly munges “&” to “&”, so it needs editing after copying

    Good catch! I also added pastebin links to make it easier: