Skip to content

Instantly share code, notes, and snippets.

View frontend-sensei's full-sized avatar
🪙

Yaroslav Gulnazaryan frontend-sensei

🪙
View GitHub Profile
@frontend-sensei
frontend-sensei / convert.js
Created February 10, 2024 11:55
Convert SVG colors to Black and white
function convertColorsToTotalBlackAndWhite(svgString) {
const BLACK_THRESHOLD = 128;
const WHITE_THRESHOLD = 127;
const convertColor = (color) => {
if (color.toLowerCase() === 'none') {
return color; // Leave "none" unchanged
}
const hexToDecimal = (hex) => parseInt(hex, 16);
function wait(milliseconds) {
return new Promise((resolve, reject) => {
setTimeout(resolve, milliseconds);
});
}
function waitForSelector(selector) {
const wait = new Promise((resolve, reject) => {
let checkExist = setInterval(function () {
if (document.querySelector(selector)) {