您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds missing sort options
当前为
// ==UserScript== // @name DeGiro improved filters // @namespace https://yelidmod.com/degiro // @version 0.1 // @description Adds missing sort options // @author DonNadie // @match https://trader.degiro.nl/* // @grant none // ==/UserScript== // jshint esversion: 6 (function() { 'use strict'; let filterIndex; const sortButton = '<i role="img" data-name="icon" data-type="sort" aria-hidden="true" class="ife-sort-icon"><svg viewBox="0 0 24 24"><path d="M16.8 13.2L12 18l-4.8-4.8h9.6zM12 6l4.8 4.8H7.2L12 6z"></path></svg></i>'; const addStyle = (styleString) => { const style = document.createElement('style'); style.textContent = styleString; document.head.append(style); }; const sort = () => { const trList = document.querySelectorAll('[data-name="productTypeSearch"] tr'); new Promise((resolve, reject) => { let list = []; let val; trList.forEach((tr, e) => { tr.querySelectorAll('td').forEach((td, i) => { if (i === filterIndex) { val = parseInt(td.innerText.replace(".", "")); list.push({ tr: tr, value : isNaN(val) ? 0 : val }); } }); if (e == (trList.length - 1)) { resolve(list); } }); }).then(list => { list.sort((a, b) => (a.value < b.value) ? 1 : -1); list.forEach(entry => { document.querySelector('[data-name="productTypeSearch"] tbody').appendChild(entry.tr); }); }); }; const onLoaded = () => { document.querySelectorAll('[data-name="productTypeSearch"] th').forEach((el, i) => { if (el.innerText != "Volumen") { return; } filterIndex = i; el.classList.add('ife-container'); el.innerHTML += sortButton; el.addEventListener("click", sort); }); }; addStyle(` .ife-container { align-items: center; display: flex; flex-direction: row; padding-right: 12px; position: relative; } .ife-sort-icon { contain: strict; display: inline-block; flex-shrink: 0; font-style: normal; font-weight: 400; line-height: 1; opacity: 1; overflow: hidden; width: 20px; height: 20px; text-align: center; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; vertical-align: middle; position: absolute; right: -8px; top: 50%; transform: translateY(-50%); cursor: pointer; } `); let appLoadedInterval = setInterval(() => { if (document.querySelectorAll('[data-name="productTypeSearch"] th').length > 0) { clearInterval(appLoadedInterval); onLoaded(); } }, 1000); })();