您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
This script makes it so you can navigate marketplace with arrow keys between next and previous pages. It also attemps to remove duplicates from results(highly imperfect).
当前为
// ==UserScript== // @name Arrow Keys navigate Marketplace // @namespace http://tampermonkey.net/ // @version 0.8 // @license MIT // @description This script makes it so you can navigate marketplace with arrow keys between next and previous pages. It also attemps to remove duplicates from results(highly imperfect). // @author Aida Beorn // @match https://marketplace.secondlife.com/* // @icon https://www.google.com/s2/favicons?domain=secondlife.com // @grant None // ==/UserScript== function NextPage() { let next = document.getElementsByClassName('next_page')[0]; if(next) { next.click(); } } function PreviousPage() { let prev = document.getElementsByClassName('previous_page')[0]; if(prev) { prev.click(); } } function HandleKeyEvent(e) { switch(e.key) { case "ArrowRight": NextPage(); break; case "ArrowLeft": PreviousPage(); break; } } (function() { 'use strict'; document.addEventListener('keydown', HandleKeyEvent); //RemoveDuplicates(); })(); function RemoveDuplicates() { let items1 = Array.from(document.getElementsByClassName('gallery-item')); let items2 = Array.from(document.getElementsByClassName('gallery-item')); let count = 0; const maxDistance = 10; const filterGatcha = true; const filterDuplicates = true; const debuging = true; const gachaTerms = [ "gacha", "rare", "common" ]; items1.forEach((item1, idx1) => { items2.forEach((item2, idx2) => { if(idx1 !== idx2) { const levDistance = levenshteinDistance(item1.children[1].innerText, item2.children[1].innerText); if(levDistance < maxDistance && levDistance !== 0) { if(debuging) { console.log(`${item1.children[1].innerText}::${item2.children[1].innerText}::${levDistance}`); } item2.remove(); delete items1[idx1]; delete items2[idx2]; count++; } } }) }) if(filterGatcha) { let items = Array.from(document.getElementsByClassName('gallery-item')); for(let j = 0; j < items.length; j++) { const item = items[j]; const itemLower = item.children[1].innerText.toLowerCase(); if (gachaTerms.some(v => itemLower.includes(v))) { if(debuging) { console.log(itemLower); } item.remove(); count++; } } } console.log(`Removed ${count} items`); } function levenshteinDistance(a, b){ if(a.length == 0) return b.length; if(b.length == 0) return a.length; var matrix = []; // increment along the first column of each row var i; for(i = 0; i <= b.length; i++){ matrix[i] = [i]; } // increment each column in the first row var j; for(j = 0; j <= a.length; j++){ matrix[0][j] = j; } // Fill in the rest of the matrix for(i = 1; i <= b.length; i++){ for(j = 1; j <= a.length; j++){ if(b.charAt(i-1) == a.charAt(j-1)){ matrix[i][j] = matrix[i-1][j-1]; } else { matrix[i][j] = Math.min(matrix[i-1][j-1] + 1, // substitution Math.min(matrix[i][j-1] + 1, // insertion matrix[i-1][j] + 1)); // deletion } } } return matrix[b.length][a.length]; };