Amazon Wish List Custom Items

Add custom items to your wish list. Links to eBay and external sites. Replaces idea list image with yellow lightbulb.

اعتبارا من 31-07-2021. شاهد أحدث إصدار.

// ==UserScript==
// @name         Amazon Wish List Custom Items
// @version      0.1
// @description  Add custom items to your wish list. Links to eBay and external sites. Replaces idea list image with yellow lightbulb.
// @author       asheroto
// @namespace    https://greasyfork.dpdns.org/en/scripts/430176-amazon-wish-list-custom-items
// @match        https://www.amazon.com/gp/registry/wishlist/*
// @match        https://www.amazon.com/hz/wishlist/*
// ==/UserScript==

(function () {
	// Set length
	var g_length = 0;

	// Match maker
	function e_match(elem, ih_match, regexPattern, replaceThis, hrefPrepend, hrefText) {
		try {
			// If keyword matches
			if (elem.innerHTML.includes(ih_match)) {
				// Match regex pattern
				var e_matches = elem.innerHTML.match(regexPattern);

				// Get number of matches
				var e_length = e_matches.length;

				// If at least 1 match
				if (e_length > 0) {
					// Replace data
					var e_href = hrefPrepend + e_matches[0].replace(replaceThis, "");

					// Create link
					var e_result = '<a href="' + e_href + '" target="_blank">' + hrefText + "<a/>";

					// Replace data in DOM
					elem.innerHTML = e_result;
				}
			}
		} catch (e) {}

		return true;
	}

	// Checker
	function check() {
		// Get all comments box elements
		let wt = document.getElementsByClassName("wrap-text");
		let wt_length = wt.length;
		for (var i = 0; i <= wt_length - 1; i++) {
			// Get element
			var elem = document.getElementsByClassName("wrap-text")[i];

			// eBay
			e_match(elem, "ebay:", "\\bebay:(.*)\\S", "ebay:", "https://www.ebay.com/sch/i.html?_nkw=", '<img src="https://svgur.com/i/Zhh.svg" width="75x"></img>');

			// URL
			e_match(elem, "url:", "\\burl:(.*)\\S", "url:", "", "External Website");
		}

		// Get all idea images
		let ii = document.getElementsByTagName("img");
		let ii_length = ii.length;
		for (i = 0; i <= ii_length - 1; i++) {
			// Get element
			var elemI = ii[i];

			// Image
			var img = elemI.src;
			if (img.includes("wfa_idea")) {
				// Replace img src
				var i_result = "https://i.ibb.co/6vf3qNs/idea.png";

				// Replace data in DOM
				elemI.src = i_result;
				elemI.width = "135";
				elemI.height = "135";
			}
		}
	}

	// Check if page has changed by comparing length
	function runCheck() {
		let gil = document.getElementById("g-items").innerHTML.length;
		if (gil > g_length) {
			g_length = gil;
			check();
		}
	}

	// Run check every 2 seconds
	var repeat = setInterval(runCheck, 2000);

	// Initial run
	runCheck();
})();
长期地址
遇到问题?请前往 GitHub 提 Issues,或加Q群1031348184

赞助商

Fishcpy

广告

Rainyun

注册一下就行

Rainyun

一年攒够 12 元