// ==UserScript== // @name 研招网助手 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 现有功能:辅助查询计划余额信息 - 2023.04.07 // @author D1n910 && ChatGPT // @license MIT // @match https://yz.chsi.com.cn/sytj/tj/qecx.html // @icon https://www.google.com/s2/favicons?sz=64&domain=chsi.com.cn // @grant none // @grant GM_addStyle // @grant GM_xmlhttpRequest // @grant unsafeWindow // @run-at document-end // @downloadURL none // ==/UserScript== function showNotification(text) { const message = document.createElement('div'); message.style.backgroundColor = 'rgba(31, 175, 233, 1)'; message.style.color = '#fff'; message.style.position = 'fixed'; message.style.top = '-50px'; message.style.left = '0'; message.style.width = '100%'; message.style.padding = '10px'; message.style.textAlign = 'center'; message.style.fontSize = '18px'; message.style.fontWeight = 'bold'; message.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.3)'; message.style.zIndex = 100000; message.innerText = text; document.body.appendChild(message); setTimeout(function () { message.style.transition = 'top 0.1s'; message.style.top = '0'; setTimeout(function () { message.style.transition = 'top 0.3s ease'; message.style.top = '-50px'; setTimeout(function () { message.remove(); }, 200); }, 800); }, 10); } (function() { 'use strict'; var div = document.createElement("div"); div.id = "app"; document.body.appendChild(div); var fixButton = document.createElement('div'); setStyle(fixButton,{ width: '1', height: '32px', }); // 样式函数 function setStyle(dom,options,fn){ new Promise(function(resolve,reject){ for (let key in options){ dom.style[key] = options[key]; } resolve(); }).then(res => { if (fn) { fn() } }).catch(err => { console.log(err) }) } // 引入Vue和axios if (typeof Vue === 'undefined') { var script = document.createElement('script'); script.src = 'https://cdn.bootcdn.net/ajax/libs/vue/2.6.14/vue.min.js'; script.onload = function() { if (typeof axios === 'undefined') { var script2 = document.createElement('script'); script2.src = 'https://cdn.bootcdn.net/ajax/libs/axios/0.21.4/axios.min.js'; script2.onload = function() { // Your function here... window.Vue.component('school-list', { data: function() { return { schools: [], currentIndex: 0, prevIndex: -1, nextIndex: 1 }; }, created: function() { var vm = this; // 发送 AJAX 请求获取学校列表 window.axios .get('http://127.0.0.1:3000/targetInstitution') .then(function(response) { vm.schools = response.data.schools; }) .catch(function(error) { console.log(error); }).finally(() => { var tjmain = document.querySelector("body > div.tj-main"); setStyle(tjmain,{ paddingTop: '209px' }); setTimeout(() => { this.search(); }, 10) }); }, methods: { copySchoolNameAndTime: function() { var schoolName = this.schools[this.currentIndex]; var now = new Date(); /** var timeString = now.getFullYear() + '/' + (now.getMonth() + 1) + '/' + now.getDate() + ' ' + now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds(); **/ // var copyText = schoolName + ' ' + timeString; var copyText = schoolName; navigator.clipboard .writeText(copyText) .then(() => { showNotification('已复制到剪切板:' + copyText); // alert('已复制到剪切板:' + copyText); }) .catch(function(error) { console.log(error); }); }, prevSchool: function() { if (this.prevIndex < 0) { this.$refs.prevSchoolText.innerText = '[最顶部]'; this.$refs.prevSchoolButton.disabled = true; } else { this.$refs.nextSchoolButton.disabled = false; this.$refs.prevSchoolText.innerText = this.schools[this.prevIndex]; this.nextIndex = this.currentIndex; this.currentIndex = this.prevIndex; this.prevIndex--; } this.search(); }, nextSchool: function() { if (this.nextIndex >= this.schools.length) { this.$refs.nextSchoolText.innerText = '[最底部]'; this.$refs.nextSchoolButton.disabled = true; } else { this.$refs.prevSchoolButton.disabled = false; this.$refs.nextSchoolText.innerText = this.schools[this.nextIndex]; this.prevIndex = this.currentIndex; this.currentIndex = this.nextIndex; this.nextIndex++; } this.search(); }, search() { document.querySelector("#dwxx").value = this.schools[this.currentIndex]; document.querySelector("#tj_seach_form > table > tbody > tr > td:nth-child(11) > a").click(); } }, template: `