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 && 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 && 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>
Add comment