您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Detect duplicate items
当前为
// ==UserScript== // @name Google Shopping Duplicates // @namespace https://www.latinsud.com // @version 0.3 // @description Detect duplicate items // @author LatinSuD // @match https://shoppinglist.google.com/lists/* // @grant none // ==/UserScript== (function() { 'use strict'; var mydivd=document.createElement('DIV'); document.body.appendChild(mydivd) mydivd.style="position: fixed; left: 3em; top: 0; z-index: 9999"; var retraso=null; // Esta es la chicha function calcular() { console.log("Checking duplicates...") var lista=Array.from(document.body.querySelectorAll('SPAN.listItemTitle')); var dups="" lista.forEach(function(e) { lista.some(function(f) { if (e==f) { return true; } // Try and detect plurals. This works better with spanish words. if (e.textContent.trim().toUpperCase().replace(/E?S *$/,"") == f.textContent.trim().toUpperCase().replace(/E?S *$/,"")) { dups=dups+e.textContent +", "; //console.log("BIEN"); } }) }) mydivd.innerHTML="Duplicates: " + dups; } /****************************************/ /* CONFIGURAMOS EL OBSERVER Y EL TIMER */ /****************************************/ // selecciona el nodo target var target = document.querySelector('#some-id'); // Configura el observer: var config = { attributes: false, childList: false, characterData: true, subtree: true }; // Crea una instancia de observer var observer = new MutationObserver(function(mutations) { //console.log(mutations) if (retraso) clearTimeout(retraso); retraso=setTimeout(calcular, 1000); //console.log("FIN MUTACION") // pasa al observer el nodo y la configuracion //observer.observe(document.body, config); }); // pasa al observer el nodo y la configuracion observer.observe(document.body, config); })();