您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
广东省气象业务网数值预报页面修改
当前为
// ==UserScript== // @name NWP helper in GuangDong // @description 广东省气象业务网数值预报页面修改 // @namespace minhill.com // @include http://10.148.8.228/to_fore_homepage.action* // @version 0.32 // @grant GM_addStyle // @license The MIT License (MIT); http://opensource.org/licenses/MIT // @compatible firefox // @compatible chrome // @compatible edge // @note 2018/01/08 增加时效转换按钮 // @supportURL https://gf.qytechs.cn/scripts/26259 // @author Hanchy Hill // ==/UserScript== // select the target node let userConfig = { // 用户设置 alterDate : false, // 默认不修改时次 } var NWP_init = function(){ var fcHour = document.getElementById('forecast_hour'); var iniTime = document.getElementById('create_day'); var infoBar = document.getElementById('pic_info'); var referNode = document.getElementById('to_contrast'); var divTime = document.createElement('span'); divTime.textContent = 'hello world'; divTime.setAttribute('class', 'lcTime'); divTime.style.position = 'relative'; divTime.style.float = 'right'; divTime.style.right = '120px'; infoBar.insertBefore(divTime, referNode); // document.querySelector("#forecast_hours div").textContent = "日期"; // create an observer instance var UTC8 = new MutationObserver(function (mutations) { var dateString = iniTime.textContent.match(/(\d+).*?(\d+).*?(\d+).*?(\d+)/); var fcDate = []; fcDate[0] = Number(dateString[1]); fcDate[1] = Number(dateString[2]); fcDate[2] = Number(dateString[3]); fcDate[3] = Number(dateString[4]); fcDate[4] = Number(fcHour.textContent.match(/\d+/)); fcDate[5] = new Date(fcDate[0], fcDate[1] - 1, fcDate[2], fcDate[3] + fcDate[4] + 8); var localTime = String(fcDate[5].getMonth() + 1) + '月' + fcDate[5].getDate() + '日' + fcDate[5].getHours() + '时 GMT+8'; divTime.textContent = localTime; }); // configuration of the observer: var config = { attributes: true, childList: true, characterData: true }; UTC8.observe(fcHour, config); // later, you can stop observing //observer.disconnect(); // // ///////////////////////////////////////////////////////////// // /// ////////////////////修改时效列///////////////////////////////////////// var alterTimelist = function (mutations) { //alert(timeBar.length); if(!userConfig.alterDate) return; // 不修改则直接返回 var dateString = iniTime.textContent.match(/(\d+).*?(\d+).*?(\d+).*?(\d+)/); var fcDate = []; fcDate[0] = Number(dateString[1]); fcDate[1] = Number(dateString[2]); fcDate[2] = Number(dateString[3]); fcDate[3] = Number(dateString[4]); for (let i = 0; i < timeBar.length; i++) { oValue = timeBar[i].value fcDate[4] = Number(timeBar[i].value); fcDate[5] = new Date(fcDate[0], fcDate[1] - 1, fcDate[2], fcDate[3] + fcDate[4] + 8); iday = String(fcDate[5].getDate()); iday = Array(2 > iday.length ? 2 - iday.length + 1 || 0 : 0).join(0) + iday; ihour = String(fcDate[5].getHours()); ihour = Array(2 > ihour.length ? 2 - ihour.length + 1 || 0 : 0).join(0) + ihour; localTime = iday+' ' + ihour+' ;'; styleText = '#'+timeBar[i].getAttribute("id")+':before{white-space:pre;content: " '+localTime+' "}'; GM_addStyle(styleText); switch(fcDate[5].getHours()){ case 5: timeBar[i].style.cssText = "border-left:2px solid #9B30FF"; break; case 14: timeBar[i].style.cssText = "border-left:2px solid #EE3B3B"; break; case 20: timeBar[i].style.cssText = "border-bottom:1px dotted #8E8E8E;border-left:2px solid #ffffff;"; break; default: timeBar[i].style.cssText = "border-left:2px solid #ffffff;"; } } } ///////////////////////////////////////////////////////////// /// var selectObserver = new MutationObserver(alterTimelist); // configuration of the observer: var timeBar = document.querySelector("#forecast_hours select"); var config2 = { attributes: false, childList: true, characterData: false }; selectObserver.observe(timeBar, config2); GM_addStyle("#forecast_hours option{width: 50px!important; overflow: hidden!important;}"); //-----------------------------------------------------------------------------// //------------------------------24小时跳跃-------------------------------------// var timeJump = function(){ //var hourBar = document.getElementById('from_hour');float-l var jumpParent = document.querySelector('.float-l') var pre24 = document.createElement('button'); pre24.addEventListener("click", function(){timeTrigger(-24)}); pre24.textContent = "-24"; jumpParent.appendChild(pre24); var next24 = document.createElement('button'); next24.addEventListener("click", function(){timeTrigger(24)}); next24.textContent = "+24"; jumpParent.appendChild(next24); var timeTrigger = function(timer){ selectedVal = timeBar[timeBar.selectedIndex].getAttribute("data-hour"); nextVal = String(Number(selectedVal) + timer); var posi = 3; nextVal = Array(posi > nextVal.length ? posi - nextVal.length + 1 || 0 : 0).join(0) + nextVal; nextopt = timeBar.querySelector("#option_"+nextVal); //alert(nextopt); if(!nextopt) return; timeBar[timeBar.selectedIndex].selected = false nextopt.selected = true; //var oitem = document.getElementById('option_018'); //oitem.selected = true; var changeEvt = document.createEvent('HTMLEvents'); changeEvt.initEvent('change',true,true); timeBar.dispatchEvent(changeEvt); } } timeJump(); /////切换时效 function switchDate(){ userConfig.alterDate = !userConfig.alterDate; if(userConfig.alterDate){ switchDateBtn.textContent = "切换成时效"; alterTimelist(); } else{ switchDateBtn.textContent = "切换成日期"; for(let ele of timeBar){ ele.style.cssText = ''; styleText = '#'+ele.getAttribute("id")+':before{white-space:pre;content: ""}'; GM_addStyle(styleText); } } }; var switchParent = document.querySelector('.float-l') let switchDateBtn = document.createElement('button'); switchDateBtn.addEventListener("click", switchDate); switchDateBtn.textContent = "切换成日期"; switchParent.appendChild(switchDateBtn); /////end 切换时效 ///// } NWP_init();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址