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;}})();
  • CrulOP
    link
    fedilink
    arrow-up
    3
    ·
    10 months ago

    If you can think of a better title for this post, please let me know… I couldn’t come up with a better one.

    cc @Zeus@lemm.ee you may find this useful

    • zeus ⁧ ⁧ ∽↯∼
      link
      fedilink
      English
      arrow-up
      2
      arrow-down
      1
      ·
      edit-2
      8 months ago

      yes i do, thank you. very much so

      by the way, you might want to add that lemmy 0.18.4 currently incorrectly munges “&” to “&”, so it needs editing after copying

      edited version (partly for my own backup) that works on artstation sites as well (remember to replace the &s)
      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 = `[${ 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 = "beige";
      		inpt.style.background = "#282828";
      		inpt.style.top = "5vh";
      		inpt.style.left = "5vw";
      		inpt.style.height = "90vh";
      		inpt.style.width = "45vw";
      		inpt.style.border = "solid 2px firebrick";
      		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 = "firebrick";
      		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 = "";
      		if (document.location.host.endsWith("www.artstation.com")) {
      			var title = document.querySelector(".project-description-title");
      			var author = document.querySelector(".project-author-name h3 a");
      			var profileUrl = document.querySelector(".project-author-name a").href;
      			var description = document.querySelector(".project-description p:first-child");
      		} else {
      			var title = document.querySelector(".project-page .project-section:first-child");
      			var author = document.querySelector(".site-title a");
      			var profileUrl = "https://www.artstation.com/" + author.href.split(/[\/\.]/)[2];
      			var description = document.querySelector(".project-page .project-description");
      		}
      		if (!title || !author) {
      			return
      		}
      		var image = document.querySelector("picture:first-of-type img").src.split("?")[0].replace(/(small|medium|4k)/, "large")
      		title = title.innerText.replace("[", "\\[").replace("]", "\\]");
      		if (description && description.innerText) {
      			description = description.innerText.replaceAll("\n", "\r\n> \r\n> ");
      			sourceCode += `> ${description}\r\n\r\n`
      		}
      		sourceCode += `source: [artstation site](https://${profileUrl.split("/").slice(-1)[0]}.artstation.com/projects/${document.location.href.split("/").slice(-1)[0]})`;
      		sourceCode += ` ||\r\n[artstation page](https://www.artstation.com/artwork/${document.location.href.split("/").slice(-1)[0]})`;
      		sourceCode += `\r\n\r\nartist's: [artstation site](https://${profileUrl.split("/").slice(-1)[0]}.artstation.com/`;
      		sourceCode += ` ||\r\n[artstation page](${profileUrl})`;
      		sourceCode += ` ||\r\n[artstation rss feed](${profileUrl}.rss)\r\n`;
      		sourceCode += "\"" + title + "\"" + " by " + author.innerText + "\r\n";
      		sourceCode += image
      		return sourceCode
      	}
      })();
      
      • CrulOP
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        10 months 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: