Skip to content

Instantly share code, notes, and snippets.

@Neoklosch
Last active November 17, 2019 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Neoklosch/d7adc4dad723898df5d4faaea6d34e78 to your computer and use it in GitHub Desktop.
Save Neoklosch/d7adc4dad723898df5d4faaea6d34e78 to your computer and use it in GitHub Desktop.
Vexels script
main.js
function setupGetInfo(tabId) {
const code = `(function getInfo() {
var title = document.getElementById('vector_title').innerText.toLowerCase()
.replace(" t-shirt design", "")
.replace(" tshirt design", "")
.replace("t-shirt design", "")
.replace("tshirt design", "")
.trim();
title = title[0].toUpperCase() + title.slice(1);
title = title + ";";
var description = document.getElementsByClassName("blk__content-detail")[0].innerText
.replace("Can be used on t-shirts, hoodies, mugs, posters and any other merchandise.", "")
.replace("Ready to use on Merch by Amazon, and other print-on-demand platforms like Redbubble, Teespring, Printful and others.", "")
.replace("Also eligible to be used on KDP.", "")
.replace("Also eligible to use on KDP.", "")
.replace("Suitable for t-shirt and other carious prints", "")
.replace("Perfect for tee prints and more!", "")
.replace("Print ready", "")
.trim()
.replace("T-shirt design featuring", "")
.replace("Tshirt design featuring", "")
.replace("Nice t-shirt design featuring", "")
.replace("Nice tshirt design featuring", "")
.replace("Cool t-shirt design featuring", "")
.replace("Cool tshirt design featuring", "")
.replace("Cool tshirt design featuring", "")
.replace("Cool t-shirt design featring", "")
.replace("This Graphic Tee design can be used on shirts, mugs, posters, hoodies and other merch products.", "")
.replace("Comes with a transparent PNG file, perfect for POD platforms like Merch by Amazon, Redbubble, Teespring, Printful and KDP.", "")
.replace("Cool Christmas t-shirt design featuring", "")
.replace("Eligible to be used on POD platforms like KDP, Merch by Amazon, Teespring, Redbubble, Printful and more.", "")
.replace("Christmas t-shirt design featuring", "")
.replace("Cute t-shirt design featuring", "")
.trim();
description = description[0].toUpperCase() + description.slice(1);
description = description + ";";
var tags = Array.from(document.getElementsByClassName("blk__tags-list")[0]
.getElementsByTagName("a"))
.filter(entry => entry.className == "tag")
.map(entry => entry.innerText.toLowerCase().trim())
.filter(entry => !["design", "print", "tee design", "t-shirts", "tshirts", "royalty-free", "graphic tshirt", "professional use", "t-shirt design", "print ready", "pod", "t-shirt", "tshirt", "tee", "shirt", "merch", "kdp", "print-on-demand", "print on demand", "graphic tee", "graphic shirt", "commercial use", "royalty free", "tee-shirt design", "print reade", "kindle direct publishing", "graphic t-shirt"].includes(entry.toLowerCase()));
tags.push("gift");
return ";;;" + title + description + tags.join(",") + ",geschenk;" + title + description + tags.join(",") + ";1;1;1;1;1;17;white;;44;;";
})()`;
chrome.tabs.executeScript(tabId, { code }, function(result) {
navigator.clipboard
.writeText(result)
.then(() => alert("Copied to clipboard~"))
.catch(() => alert("Failed to copy to clipboard..."));
});
}
chrome.tabs.query({ active: true, windowId: chrome.windows.WINDOW_ID_CURRENT }, function (tabs) {
const { id: tabId } = tabs[0].url;
setupGetInfo(tabId);
});
manifest.json
{
"manifest_version": 2,
"name": "vexels fetcher",
"description": "Fetch vexels information",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"activeTab"
]
}
popup.html
<!doctype html>
<html>
<head>
<title>Fetch vexels information</title>
</head>
<body>
<p>Done</p>
</body>
<script src="main.js"></script>
</html>
go to "chrome://extensions" -> Developer mode -> load unpacked extension
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment