我正在尝试使用TamperMonkey/Userscript对搜索结果进行排序。结果以Customer:,Case:,Inventory:,PNG:等开头。下面是搜索结果中的HTML,但我无论如何都找不到这些页面上的自定义订单??
/*
* 提示:该行代码过长,系统自动注释不进行高亮。一键复制会移除系统注释
* <div class="uir-tooltip-content"><ul id="uir-global-search-container" role="listbox" style="min-width: 550px; display: block;"><li class="uir-global-search-item"><a role="option" class="uir-item-view" href="/app/common/media/mediaitem.nl?id=3904965" id="/app/common/media/mediaitem.nl?id=3904965">PNG Image: <span>Bank Transfer Receipt Thermo Invoice 67578.PNG</span></a><a class="uir-item-edit" href="/app/common/media/mediaitem.nl?id=3904965&e=T" id="edit_/app/common/media/mediaitem.nl?id=3904965" aria-label="Edit PNG Image:Bank Transfer Receipt Thermo Invoice 67578.PNG">Edit</a></li><li class="uir-global-search-item"><a role="option" class="uir-item-view" href="/app/common/media/mediaitem.nl?id=4380864" id="/app/common/media/mediaitem.nl?id=4380864">PNG Image: <span>Bank Transfer Receipt Thermo Invoice 71546.PNG</span></a><a class="uir-item-edit" href="/app/common/media/mediaitem.nl?id=4380864&e=T" id="edit_/app/common/media/mediaitem.nl?id=4380864" aria-label="Edit PNG Image:Bank Transfer Receipt Thermo Invoice 71546.PNG">Edit</a></li><li class="uir-global-search-item"><a role="option" class="uir-item-view" href="/app/common/media/mediaitem.nl?id=4230494" id="/app/common/media/mediaitem.nl?id=4230494">PNG Image: <span>Bank Transfer Receipt Thermo January Invoices.PNG</span></a><a class="uir-item-edit" href="/app/common/media/mediaitem.nl?id=4230494&e=T" id="edit_/app/common/media/mediaitem.nl?id=4230494" aria-label="Edit PNG Image:Bank Transfer Receipt Thermo January Invoices.PNG">Edit</a></li><li class="uir-global-search-item"><a role="option" class="uir-item-view" href="/app/common/media/mediaitem.nl?id=5049467" id="/app/common/media/mediaitem.nl?id=5049467">PDF File: <span>BOQ IB - Transfers & BPAY - Thermogroup.pdf</span></a><a class="uir-item-edit" href="/app/common/media/mediaitem.nl?id=5049467&e=T" id="edit_/app/common/media/mediaitem.nl?id=5049467" aria-label="Edit PDF File:BOQ IB - Transfers & BPAY - Thermogroup.pdf">Edit</a></li><li class="uir-global-search-item"><a role="option" class="uir-item-view" href="/app/common/media/mediaitem.nl?id=5168179" id="/app/common/media/mediaitem.nl?id=5168179">PDF File: <span>BOQ IB - Transfers & BPAY THERMO.pdf</span></a><a class="uir-item-edit" href="/app/common/media/mediaitem.nl?id=5168179&e=T" id="edit_/app/common/media/mediaitem.nl?id=5168179" aria-label="Edit PDF File:BOQ IB - Transfers & BPAY THERMO.pdf">Edit</a></li><li class="uir-global-search-item"><a role="option" class="uir-item-view" href="/app/common/media/mediaitem.nl?id=5661633" id="/app/common/media/mediaitem.nl?id=5661633">PDF File: <span>BOQ IB - Transfers & BPAY.pdf</span></a><a class="uir-item-edit" href="/app/common/media/mediaitem.nl?id=5661633&e=T" id="edit_/app/common/media/mediaitem.nl?id=5661633" aria-label="Edit PDF File:BOQ IB - Transfers & BPAY.pdf">Edit</a></li><li class="uir-global-search-item"><a role="option" class="uir-item-view" href="/app/crm/common/crm.nl?id=1056272" id="/app/crm/common/crm.nl?id=1056272">Case: <span>C10118 You've been sent the details of a NetBank tra... (3077 Ascot Bathroomware)</span></a><a class="uir-item-edit" href="/app/crm/common/crm.nl?id=1056272&e=T" id="edit_/app/crm/common/crm.nl?id=1056272" aria-label="Edit Case:C10118 You've been sent the details of a NetBank tra... (3077 Ascot Bathroomware)">Edit</a></li><li class="uir-global-search-item"><a role="option" class="uir-item-view" href="/app/crm/common/crm.nl?id=1262175" id="/app/crm/common/crm.nl?id=1262175">Case: <span>C12226 You've been sent the details of a NetBank tra... (2268 Tile Power Penrith)</span></a><a class="uir-item-edit" href="/app/crm/common/crm.nl?id=1262175&e=T" id="edit_/app/crm/common/crm.nl?id=1262175" aria-label="Edit Case:C12226 You've been sent the details of a NetBank tra... (2268 Tile Power Penrith)">Edit</a></li><li class="uir-global-search-item"><a role="option" class="uir-item-view" href="/app/crm/common/crm.nl?id=1395573" id="/app/crm/common/crm.nl?id=1395573">Case: <span>C13603 You've been sent the details of a NetBank tra... (0378 Solartex Insulation)</span></a><a class="uir-item-edit" href="/app/crm/common/crm.nl?id=1395573&e=T" id="edit_/app/crm/common/crm.nl?id=1395573" aria-label="Edit Case:C13603 You've been sent the details of a NetBank tra... (0378 Solartex Insulation)">Edit</a></li><li class="uir-global-search-item"><a role="option" class="uir-item-view" href="/app/crm/common/crm.nl?id=1624647" id="/app/crm/common/crm.nl?id=1624647">Case: <span>C15969 You've been sent the details of a NetBank tra... (0378 Solartex Insulation)</span></a><a class="uir-item-edit" href="/app/crm/common/crm.nl?id=1624647&e=T" id="edit_/app/crm/common/crm.nl?id=1624647" aria-label="Edit Case:C15969 You've been sent the details of a NetBank tra... (0378 Solartex Insulation)">Edit</a></li><li><a id="showMoreItems" class="uir-item-view uir-global-search-more" href="/app/common/search/ubersearchresults.nl?Uber_NAME=transfer&quicksearch=T&searchtype=Uber&frame=be&Uber_NAMEtype=KEYWORDSTARTSWITH">Show more results</a></li></ul></div>
*/发布于 2021-06-04 22:01:20
我想这不是最好的方法,但你可以尝试这样做:
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.w3schools.com/jsref/dom_obj_document.asp
// @icon https://www.google.com/s2/favicons?domain=w3schools.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
var UL = document.getElementById("uir-global-search-container");
if (UL.hasChildNodes()) {
var LIs = Array.from(UL.getElementsByClassName("uir-global-search-item"));
var newLIs;
LIs.forEach(li => {
UL.removeChild(li);
});
var moreLink = UL.lastChild;
UL.removeChild(moreLink);
LIs.forEach(li => {
if(li.innerHTML.includes("Customer:")) {UL.appendChild(li); }
});
LIs.forEach(li => {
if(li.innerHTML.includes("Case:")) UL.appendChild(li);
});
LIs.forEach(li => {
if(li.innerHTML.includes("Inventory:")) UL.appendChild(li);
});
LIs.forEach(li => {
if(li.innerHTML.includes("PNG Image:")) UL.appendChild(li);
});
LIs.forEach(li => {
if(li.innerHTML.includes("PDF File:")) UL.appendChild(li);
});
UL.appendChild(moreLink);
}
})();https://stackoverflow.com/questions/64501855
复制相似问题