// ==UserScript== // @name Torn圣诞小镇解密攻略 // @namespace WH // @version 0.1.1 // @description 显示解密攻略 // @author Woohoo[2687093] // @match https://www.torn.com/* // @grant none // ==/UserScript== (function () { 'use strict'; const ___window___ = window || window.unsafeWindow; if (___window___.WHXMAS||___window___.WHTRANS) return; ___window___.WHXMAS = true; const $ = ___window___.jQuery; if (/christmas_town\.php/.test(window.location.href)) { const $root = document.querySelector('#christmastownroot'); const $city_wrapper = $root.querySelectorAll('div[class^="core-layout__"]'); const insert_html = `
水晶球解密地图攻略

来源:Torn City公众号,图文详情请查看公众号文章


`; const wt_dict = { "None": {title: '', wt: ``,}, "Christmas Town": { title: '圣诞小镇', wt: ``, }, "Maltese Snow Globe": { title: 'Maltese Snow Globe', wt: ``, }, "Long way from home": { title: 'Long way from home', wt: ``, }, "Chedburn Towers": { title: 'Chedburn Towers', wt: ``, }, "Kidnapped Santa": { title: 'Kidnapped Santa', wt: ``, }, "Holiday terror": { title: 'Holiday terror', wt: ``, }, "Among Us": { title: 'Among Us', wt: ``, }, "Kiss My Festivus": { title: 'Kiss My Festivus', wt: ``, }, "Stanley Hotel": { title: 'Stanley Hotel', wt: ``, }, "DoggoQuest": { title: 'DoggoQuest', wt: ``, }, "Pokemon CT": { title: 'Pokemon CT', wt: ``, }, "Winter in Gatlin": { title: 'Winter in Gatlin', wt: ``, }, }; $city_wrapper.forEach(el => { let $wh_container = $root.querySelector('#wh-xmas-cont'); if (!$wh_container) { $(el).prepend(insert_html); $wh_container = $root.querySelector('#wh-xmas-cont'); // 显示 隐藏 const jquery$wh_container = $($wh_container); const $cont_gray = jquery$wh_container.find('.cont-gray'); jquery$wh_container.find('button').click(e => { if (e.target.innerText === '[隐藏]') { $cont_gray.hide(); e.target.innerText = '[显示]'; } else { $cont_gray.show(); e.target.innerText = '[隐藏]'; } }); // 内容 const $wt_content = jquery$wh_container.find('#wt-content'); jquery$wh_container.find('select').change(e => { const selected = e.target.value; $wt_content.html(`

${wt_dict[selected].title}

${wt_dict[selected].wt}

`) }); } }); } }());