Created
August 21, 2023 19:14
-
-
Save dimmuboy/e3548fb38ef42b47a5aeeb5905544533 to your computer and use it in GitHub Desktop.
Show colors under thumbnails
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
// ==UserScript== | |
// @name Ali Colors | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Show colors under thumbnails | |
// @author DimmuBoy | |
// @match *://*.aliexpress.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=aliexpress.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
findThumbnails(); | |
function findThumbnails() { | |
// Get all the parent div elements with class sku-item--image--mXsHo3h | |
const parentDivs = document.querySelectorAll('.sku-item--image--mXsHo3h'); | |
// Loop through each parent div | |
parentDivs.forEach(parentDiv => { | |
// Add margin-bottom style | |
parentDiv.style.marginBottom = '4em'; | |
// Get the image element within the parent div | |
const imageElement = parentDiv.querySelector('img'); | |
// Get the alt attribute value | |
const altText = imageElement.getAttribute('alt'); | |
// Create a new paragraph element for the alt text | |
const altTextElement = document.createElement('p'); | |
altTextElement.textContent = altText; | |
// Apply styles to the alt text element | |
altTextElement.style.position = 'absolute'; | |
altTextElement.style.bottom = '-4.5em'; | |
altTextElement.style.fontSize = '.8em'; | |
altTextElement.style.fontWeight = '700'; | |
// Append the alt text element to the parent div | |
parentDiv.appendChild(altTextElement); | |
}); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment