Show hidden user added elements on Geocaching Mystery Cache Page
当前为
// ==UserScript==
// @name Geocaching Puzzle Helper
// @description Show hidden user added elements on Geocaching Mystery Cache Page
// @match http://www.geocaching.com/geocache/*
// @match https://www.geocaching.com/geocache/*
// @match http://geocaching.com/geocache/*
// @match https://geocaching.com/geocache/*
// @version 1.8
// @namespace https://gf.qytechs.cn/en/scripts/464566-geocaching-puzzle-helper
// @homepage https://gf.qytechs.cn/en/scripts/464566-geocaching-puzzle-helper
// @license MIT
// ==/UserScript==
(function() {
'use strict';
scanElemForStuff(document.getElementById("ctl00_ContentBody_ShortDescription"));
scanElemForStuff(document.getElementById("ctl00_ContentBody_LongDescription"));
showFinalLocation();
function showFinalLocation() {
var elemFN = document.getElementById("awpt_FN");
if (elemFN !== null) {
var coordElem = elemFN.parentNode.nextElementSibling.nextElementSibling.nextElementSibling;
;
// Find right sibling
if (coordElem !== null) {
var txt = coordElem.innerText;
if (txt.length > 4) {
var locElem = document.getElementById("ctl00_ContentBody_CacheInformationTable").firstElementChild.firstElementChild.firstElementChild.firstElementChild;
addButton(locElem, "FN",txt, onClickHandler, true);
}
}
}
}
function addButton(parent, text, title, onclick, bAppend=false) {
const button = document.createElement('button');
button.innerHTML = text;
button.onclick = onclick;
button.title = title;
button.addEventListener('contextmenu', (e) => e.preventDefault());
if (bAppend) {
parent.appendChild(button);
}
else {
parent.insertBefore(button, parent.firstChild);
}
return button;
}
function scanElemForStuff(elem) {
var item;
if (elem != null) {
item = getHostedLinks(elem);
if (item.length > 0) {
addButton(elem,"Hosted",item.join('\r\n'),onClickHandler);
}
item = getExtraText(elem);
if (item.length > 0) {
addButton(elem,"Extra",item.join('\r\n'),onClickHandler);
}
item = getWhiteText(elem);
if (item.length > 0) {
addButton(elem,"White Text",item.join('\r\n'),onClickHandler);
}
item = getAllComments(elem);
if (item.length > 0) {
addButton(elem,"Comments",item.join('\r\n'),onClickHandler);
}
item = getAllLinks(elem);
if (item.length > 0) {
addButton(elem,"Links",item.join('\r\n'),onClickHandler);
}
}
}
function getAllComments(rootElem) {
var comments = [];
// Fourth argument, which is actually obsolete according to the DOM4 standard, is required in IE 11
var iterator = document.createNodeIterator(rootElem, NodeFilter.SHOW_COMMENT, null, false);
var curNode;
while (curNode = iterator.nextNode()) {
comments.push(curNode.nodeValue);
}
return comments;
}
function getAllLinks(rootElem) {
var comments = [];
var iterator = rootElem.getElementsByTagName('a');
for (var i = 0; i < iterator.length; i++) {
var elem = iterator[i];
comments.push(elem.href);
}
return comments;
}
function getHostedLinks(rootElem) {
var comments = [];
var iterator = rootElem.getElementsByTagName('img');
for (var i = 0; i < iterator.length; i++) {
var elem = iterator[i];
var str = elem.src.toLowerCase();
if ((!str.includes("s3.amazonaws.com/gs-geo-images") && !str.includes(".geocaching.com") && !str.includes(".groundspeak.com")) ||
str.includes("?")) {
comments.push(str);
}
}
return comments;
}
function getWhiteText(rootElem) {
var comments = [];
var attribute1 = "color";
var values = ["#ffffff","white", "rgb(255, 255, 255)"];
var element_type = element_type || "*";
var All = rootElem.getElementsByTagName(element_type);
for (var i = 0; i < All.length; i++) {
var elem = All[i];
if (elem.getAttribute(attribute1) !== null) {
if (values.includes(elem.getAttribute(attribute1).toLowerCase())) { comments.push( elem.innerHTML); }
}
if (values.includes(elem.style.color)) { comments.push( elem.innerHTML); }
}
return comments;
}
function getExtraText(rootElem) {
var comments = [];
var attributes = ["alt", "name", "id"];
var element_type = element_type || "*";
var All = rootElem.getElementsByTagName(element_type);
for (var i = 0; i < All.length; i++) {
for (var j = 0; j < All.length; j++) {
if (All[i].getAttribute(attributes[j]) != null) { comments.push( All[i].getAttribute(attributes[j])); }
}
}
return comments;
}
function onClickHandler(e) {
alert(this.title);
return false;
}
})();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址