Userscript to generate Markdown-fomatted source info for websites (w/ extra info for ArtStation and Tumblr)

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:


<span style="color:#323232;">Source: [Page title](page_url)
</span>

For Tumblr posts the outuput is:


<span style="color:#323232;">Source: [Page title](page_url)
</span><span style="color:#323232;">
</span><span style="color:#323232;">Tumblr archive: https://site_url/archive
</span><span style="color:#323232;">
</span><span style="color:#323232;">RSS Feed: https://site_url/rss
</span>

For ArtStation pages the outuput is:


<span style="color:#323232;">Source: [Page title](page_url)
</span><span style="color:#323232;">
</span><span style="color:#323232;">> Description (if there is any)
</span><span style="color:#323232;">
</span><span style="color:#323232;">ArtStation profile: https://profile_url
</span><span style="color:#323232;">
</span><span style="color:#323232;">RSS Feed: https://profile_url.rss
</span>

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 += rnrn> ${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:


<span style="color:#323232;">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 &amp;&amp; e.href.indexOf("tumblr.com") >= 0).length > 0;if (isTumblr) {var tumblrUrl = `${document.location.protocol}//${document.location.host}`;sourceCode += "rnrnTumblr archive: " + tumblrUrl + "/archive";sourceCode += "rnrnRSS 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 &amp;&amp; description.innerText) {description = description.innerText.replaceAll("n", "  n> ");sourceCode += ` rnrn> ${description}`;}var profileUrl = document.querySelector(".project-author-name a").href;sourceCode += "rnrnArtStation profile: " + profileUrl;sourceCode += "rnrnRSS Feed: " + profileUrl + ".rss";return sourceCode;}})();
</span>
Crul,

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 you may find this useful

Zeus, (edited )

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 “&amp;”, so it needs editing after copying

edited version (partly for my own backup) that works on artstation sites as well (remember to replace the &amp;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 &amp;&amp; e.href.indexOf(“tumblr.com”) >= 0).length > 0; if (isTumblr) { var tumblrUrl = ${document.location.protocol }//${document.location.host }; sourceCode += “rnrnTumblr archive: " + tumblrUrl + “/archive”; sourceCode += “rnrnRSS 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 &amp;&amp; description.innerText) { description = description.innerText.replaceAll(“n”, “rn> rn> “); sourceCode += > ${description}rnrn } sourceCode +=source: artstation site; sourceCode += ||rnartstation page; sourceCode += rnrnartist’s: [artstation site](https://${profileUrl.split(“/”).slice(-1)[0]}.artstation.com/; sourceCode += ||rnartstation page; sourceCode += ||rnartstation rss feedrn; sourceCode += “”" + title + “”" + " by " + author.innerText + “rn”; sourceCode += image return sourceCode } })();

Crul, (edited )

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

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

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • wartaberita
  • uselessserver093
  • Food
  • aaaaaaacccccccce
  • [email protected]
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • TheResearchGuardian
  • Ask_kbincafe
  • KbinCafe
  • Testmaggi
  • Socialism
  • feritale
  • oklahoma
  • SuperSentai
  • KamenRider
  • All magazines