Last active
July 6, 2023 07:13
-
-
Save navin-moorthy/423ce9d61910feab0f34d2db86f04245 to your computer and use it in GitHub Desktop.
Site Boost Utils
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.smashingmagazine.com/2023/06/popular-devtools-tips/#5-download-all-images-on-the-page | |
$$("img").forEach(async (img) => { | |
try { | |
const src = img.src; | |
// Fetch the image as a blob. | |
const fetchResponse = await fetch(src); | |
const blob = await fetchResponse.blob(); | |
const mimeType = blob.type; | |
// Figure out a name for it from the src and the mime-type. | |
const start = src.lastIndexOf("/") + 1; | |
const end = src.indexOf(".", start); | |
let name = src.substring(start, end === -1 ? undefined : end); | |
name = name.replace(/[^a-zA-Z0-9]+/g, "-"); | |
name += "." + mimeType.substring(mimeType.lastIndexOf("/") + 1); | |
// Download the blob using a <a> element. | |
const a = document.createElement("a"); | |
a.setAttribute("href", URL.createObjectURL(blob)); | |
a.setAttribute("download", name); | |
a.click(); | |
} catch (e) {} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ref- [amesperrin](https://gist.github.com/MoOx/93c2853fee760f42d97f#gistcomment-3069259) | |
var labels = []; | |
[].slice.call(document.querySelectorAll(".js-label-link")) | |
.forEach(function(element) { | |
labels.push({ | |
name: element.textContent.trim(), | |
description: element.getAttribute("title"), | |
// using style.backgroundColor might returns "rgb(...)" | |
color: element.getAttribute("style") | |
.replace("background-color:", "") | |
.replace(/color:.*/,"") | |
.trim() | |
// github wants hex code only without # or ; | |
.replace(/^#/, "") | |
.replace(/;$/, "") | |
.trim(), | |
}) | |
}) | |
console.log(JSON.stringify(labels, null, 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment