您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
为国学大师网查询到的页码添加超链接以打开在线资源或本地PDF文件对应页面;汉典增强,去广告 Generate page links for Guoxuedashi website based on page number in the table cell element; Zdic.net that comes with enhancements and ad-blocking
当前为
// ==UserScript== // @name 国学大师页码链接工具 Guoxuedashi Page Linker 字典神器 // @namespace http://tampermonkey.net/ // @version 1.2 // @description 为国学大师网查询到的页码添加超链接以打开在线资源或本地PDF文件对应页面;汉典增强,去广告 Generate page links for Guoxuedashi website based on page number in the table cell element; Zdic.net that comes with enhancements and ad-blocking // @author [email protected] // @match *www.guoxuedashi.net/* // @match *dict.variants.moe.edu.tw/* // @match *humanum.arts.cuhk.edu.hk/Lexis/lexi-can/* // @match *www.zdic.net/* // @grant none // ==/UserScript== // 本脚本需配合浏览器扩展方可点开本地文件链接,扩展下载链接:https://chrome.google.com/webstore/detail/enable-local-file-links/nikfmfgobenbhmocjaaboihbeocackld // 扩展名称:Enable local file links;版本:v0.8.0;备用下载链接:https://crxdl.com/;文件大小为7k,下载完成后将crx文件拖动到浏览器管理扩展页(edge://extensions/)即可安装;确保管理扩展页的开发者模式打开,否则无法安装 // 汉语大字典目前可以直接访问,其他工具书PDF请重命名为拼音直接放置D盘即可调用,如字源为ziyuan.pdf、汉语大词典第1卷为hanyudacidian1.pdf,以此类推 if (window.location.href.startsWith("http://www.guoxuedashi.net/")) { // 国语辞典、异体字典与粤语字库等链接的放置及关键词复制 (function() { "use strict"; const res = document.getElementsByClassName("tit03")[0]; var keyword = res.innerText.substring(3); let link1 = `https://dict.revised.moe.edu.tw/search.jsp?md=1&word=${keyword}`; let link2 = `https://dict.variants.moe.edu.tw/variants/rbt/query_by_standard.rbt?rbtType=AJAX_INVOKE&componentId=rci_35808733_4&searchedText=${keyword}`; let link3 = `https://humanum.arts.cuhk.edu.hk/Lexis/lexi-can/`; let link4 = `http://www.czyzd.com/search?keyword=${keyword}`; let link5 = `https://www.syndict.com/w2p.php?word=${keyword}&item=hak`; let link6 = `https://www.zdic.net/hans/${keyword}`; // res.innerHTML += ` <a href="${link1}" target="_blank">📙国语辞典</a> ∣<a href="${link2}" target="_blank">📕异体字典</a> ∣<a href="${link3}" target="_blank">📒粤语字库</a> ∣<a href="${link4}" target="_blank">📘潮州字典</a> ∣<a href="${link5}" target="_blank">📓客典</a> ∣<a href="${link6}" target="_blank">📚汉典</a>`; res.innerHTML += ` ➟ <a href="${link1}" target="_blank">国语辞典</a> ∣ <a href="${link2}" target="_blank">异体字典</a> ∣ <a href="${link3}" target="_blank">粤语字库</a> ∣ <a href="${link4}" target="_blank">潮州字典</a> ∣ <a href="${link5}" target="_blank">客典</a> ∣ <a href="${link6}" target="_blank">汉典</a>`; document .querySelector( "body > div:nth-child(3) > div.info.l > div.info_content.zj.clearfix > div.info_txt2.clearfix > h2:nth-child(1) > a:nth-child(3)" ) .addEventListener("click", function() { // 关键词复制 let textArea = document.createElement("textarea"); textArea.value = keyword; document.body.appendChild(textArea); textArea.select(); document.execCommand("copy"); console.log(document.execCommand("copy")); document.body.removeChild(textArea); }); })(); } if (window.location.href.startsWith("http://www.guoxuedashi.net/")) { //《汉语大字典》 (function() { 'use strict'; const tds = document.querySelectorAll("td"); for (const td of tds) { let content = td.innerText.trim(); if (content === '汉语大字典') { let pageNumber = parseInt(td.nextElementSibling.textContent.match(/\d+/)[0]) + 0; let link = `https://homeinmists.ilotus.org/hd/hydzd3.php?st=term&kw=${pageNumber}`; td.nextElementSibling.innerHTML = `<a href="${link}" target="_blank">${td.nextElementSibling.innerHTML}</a>`; } } })(); } if (window.location.href.startsWith("http://www.guoxuedashi.net/")) { //《中华字海》 (function() { 'use strict'; const tds = document.querySelectorAll("td"); for (const td of tds) { let content = td.innerText.trim(); if (content === '中华字海') { let pageNumber = parseInt(td.nextElementSibling.textContent.match(/\d+/)[0]) + 84; let link = `file:///D:/zhonghuazihai.pdf#page=${pageNumber}`; td.nextElementSibling.innerHTML = `<a href="${link}" target="_blank">${td.nextElementSibling.innerHTML}</a>`; } } })(); } if (window.location.href.startsWith("http://www.guoxuedashi.net/")) { //《字源》兼容双链接 (function() { 'use strict'; const tds = document.querySelectorAll("td"); for (const td of tds) { let content = td.innerText.trim(); if (content === '字 源') { let matchedNumbers = td.nextElementSibling.textContent.match(/\d+/g); if (matchedNumbers && matchedNumbers.length >= 1) { for (let i = 0; i < matchedNumbers.length; i++) { let pageNumber = parseInt(matchedNumbers[i]); if (pageNumber <= 467) { pageNumber += 12; } else if (pageNumber <= 870) { pageNumber += 13; } else if (pageNumber >= 870) { pageNumber += 15; } matchedNumbers[i] = pageNumber; } let originTextArray = td.nextElementSibling.innerHTML.split(/[\u3000\s]+/); // 按全角空格分隔源文本 let link0 = `file:///D:/ziyuan.pdf#page=${matchedNumbers[0]}`; let link1 = `file:///D:/ziyuan.pdf#page=${matchedNumbers[1]}`; td.nextElementSibling.innerHTML = `<a href="${link0}" target="_blank">${originTextArray[0]}</a> <a href="${link1}" target="_blank">${originTextArray[1]}</a>`; } } } })(); } if (window.location.href.startsWith("http://www.guoxuedashi.net/")) { //《王力古汉语字典》异步加载故每隔1秒(1000毫秒)自动执行直至加载完成并完成修改 (function() { 'use strict'; let hasModified = false; // 添加一个标记,标记是否已经执行过修改操作 const intervalId = setInterval(function() { const tds = document.querySelectorAll("td"); for (const td of tds) { let content = td.innerText.trim(); if (content === '王力古汉语字典' && !hasModified) { // 添加判断语句判断是否已经修改过 let pageNumber = parseInt(td.nextElementSibling.textContent.match(/\d+/)[0]) + 113; let link = `file:///D:/wangliguhanyuzidian.pdf#page=${pageNumber}`; td.nextElementSibling.innerHTML = `<a href="${link}" target="_blank">${td.nextElementSibling.innerHTML}</a>`; hasModified = true; // 修改标记为已执行过修改操作 clearInterval(intervalId); // 停止定时器 } } }, 1000); })(); } //《汉语大词典》共12卷如下 if (window.location.href.startsWith("http://www.guoxuedashi.net/")) { //《汉语大词典》第1卷 (function() { 'use strict'; // Find all table rows const tableRows = document.querySelectorAll('table tr'); // Loop through all table rows tableRows.forEach(row => { // Find the first table cell of the row const firstCell = row.querySelector('td:first-child'); // Check if the first cell contains "汉语大词典" if (firstCell && firstCell.innerText.trim() === '汉语大词典') { // Find the third table cell of the row const thirdCell = row.querySelector('td:nth-child(3)'); // Check if the third cell contains "第1卷" if (thirdCell && thirdCell.innerText.trim().includes('第1卷')) { // Find the second table cell of the row const secondCell = row.querySelector('td:nth-child(2)'); // Check if the second cell contains "第" and "页" if (secondCell && secondCell.innerText.trim().includes('第') && secondCell.innerText.trim().includes('页')) { // Extract the page number from the second cell(最后的 + 29 表示对提取出来的页码加以调整以适应实际文件) const pageNumber = parseInt(secondCell.innerText.match(/\d+/)[0]) + 29; // Generate the page link const pageLink = `file:///D:/hanyudacidian1.pdf#page=${pageNumber}`; // Create the link element and add it to the second cell const link = document.createElement('a'); link.href = pageLink; link.target = '_blank'; link.innerHTML = secondCell.innerText.trim(); secondCell.innerHTML = ''; secondCell.appendChild(link); } } } }); })(); } if (window.location.href.startsWith("http://www.guoxuedashi.net/")) { //《汉语大词典》第2卷 (function() { 'use strict'; // Find all table rows const tableRows = document.querySelectorAll('table tr'); // Loop through all table rows tableRows.forEach(row => { // Find the first table cell of the row const firstCell = row.querySelector('td:first-child'); // Check if the first cell contains "汉语大词典" if (firstCell && firstCell.innerText.trim() === '汉语大词典') { // Find the third table cell of the row const thirdCell = row.querySelector('td:nth-child(3)'); // Check if the third cell contains "第2卷" if (thirdCell && thirdCell.innerText.trim().includes('第2卷')) { // Find the second table cell of the row const secondCell = row.querySelector('td:nth-child(2)'); // Check if the second cell contains "第" and "页" if (secondCell && secondCell.innerText.trim().includes('第') && secondCell.innerText.trim().includes('页')) { // Extract the page number from the second cell(- 1744 表示减去前卷页码,+ 29 表示对页码加以调整以适应实际文件) const pageNumber = parseInt(secondCell.innerText.match(/\d+/)[0]) - 1744 + 29; // Generate the page link const pageLink = `file:///D:/hanyudacidian2.pdf#page=${pageNumber}`; // Create the link element and add it to the second cell const link = document.createElement('a'); link.href = pageLink; link.target = '_blank'; link.innerHTML = secondCell.innerText.trim(); secondCell.innerHTML = ''; secondCell.appendChild(link); } } } }); })(); } if (window.location.href.startsWith("http://www.guoxuedashi.net/")) { //《汉语大词典》第3卷 (function() { 'use strict'; // Find all table rows const tableRows = document.querySelectorAll('table tr'); // Loop through all table rows tableRows.forEach(row => { // Find the first table cell of the row const firstCell = row.querySelector('td:first-child'); // Check if the first cell contains "汉语大词典" if (firstCell && firstCell.innerText.trim() === '汉语大词典') { // Find the third table cell of the row const thirdCell = row.querySelector('td:nth-child(3)'); // Check if the third cell contains "第3卷" if (thirdCell && thirdCell.innerText.trim().includes('第3卷')) { // Find the second table cell of the row const secondCell = row.querySelector('td:nth-child(2)'); // Check if the second cell contains "第" and "页" if (secondCell && secondCell.innerText.trim().includes('第') && secondCell.innerText.trim().includes('页')) { // Extract the page number from the second cell(- 3406 表示减去前卷页码,+ 29 表示对页码加以调整以适应实际文件) const pageNumber = parseInt(secondCell.innerText.match(/\d+/)[0]) - 3406 + 29; // Generate the page link const pageLink = `file:///D:/hanyudacidian3.pdf#page=${pageNumber}`; // Create the link element and add it to the second cell const link = document.createElement('a'); link.href = pageLink; link.target = '_blank'; link.innerHTML = secondCell.innerText.trim(); secondCell.innerHTML = ''; secondCell.appendChild(link); } } } }); })(); } if (window.location.href.startsWith("http://www.guoxuedashi.net/")) { //《汉语大词典》第4卷 (function() { 'use strict'; // Find all table rows const tableRows = document.querySelectorAll('table tr'); // Loop through all table rows tableRows.forEach(row => { // Find the first table cell of the row const firstCell = row.querySelector('td:first-child'); // Check if the first cell contains "汉语大词典" if (firstCell && firstCell.innerText.trim() === '汉语大词典') { // Find the third table cell of the row const thirdCell = row.querySelector('td:nth-child(3)'); // Check if the third cell contains "第4卷" if (thirdCell && thirdCell.innerText.trim().includes('第4卷')) { // Find the second table cell of the row const secondCell = row.querySelector('td:nth-child(2)'); // Check if the second cell contains "第" and "页" if (secondCell && secondCell.innerText.trim().includes('第') && secondCell.innerText.trim().includes('页')) { // Extract the page number from the second cell(- 5068 表示减去前卷页码,+ 29 表示对页码加以调整以适应实际文件) const pageNumber = parseInt(secondCell.innerText.match(/\d+/)[0]) - 5068 + 29; // Generate the page link const pageLink = `file:///D:/hanyudacidian4.pdf#page=${pageNumber}`; // Create the link element and add it to the second cell const link = document.createElement('a'); link.href = pageLink; link.target = '_blank'; link.innerHTML = secondCell.innerText.trim(); secondCell.innerHTML = ''; secondCell.appendChild(link); } } } }); })(); } if (window.location.href.startsWith("http://www.guoxuedashi.net/")) { //《汉语大词典》第5卷 (function() { 'use strict'; // Find all table rows const tableRows = document.querySelectorAll('table tr'); // Loop through all table rows tableRows.forEach(row => { // Find the first table cell of the row const firstCell = row.querySelector('td:first-child'); // Check if the first cell contains "汉语大词典" if (firstCell && firstCell.innerText.trim() === '汉语大词典') { // Find the third table cell of the row const thirdCell = row.querySelector('td:nth-child(3)'); // Check if the third cell contains "第5卷" if (thirdCell && thirdCell.innerText.trim().includes('第5卷')) { // Find the second table cell of the row const secondCell = row.querySelector('td:nth-child(2)'); // Check if the second cell contains "第" and "页" if (secondCell && secondCell.innerText.trim().includes('第') && secondCell.innerText.trim().includes('页')) { // Extract the page number from the second cell(- 6455 表示减去前卷页码,+ 29 表示对页码加以调整以适应实际文件) const pageNumber = parseInt(secondCell.innerText.match(/\d+/)[0]) - 6455 + 29; // Generate the page link const pageLink = `file:///D:/hanyudacidian5.pdf#page=${pageNumber}`; // Create the link element and add it to the second cell const link = document.createElement('a'); link.href = pageLink; link.target = '_blank'; link.innerHTML = secondCell.innerText.trim(); secondCell.innerHTML = ''; secondCell.appendChild(link); } } } }); })(); } if (window.location.href.startsWith("http://www.guoxuedashi.net/")) { //《汉语大词典》第6卷 (function() { 'use strict'; // Find all table rows const tableRows = document.querySelectorAll('table tr'); // Loop through all table rows tableRows.forEach(row => { // Find the first table cell of the row const firstCell = row.querySelector('td:first-child'); // Check if the first cell contains "汉语大词典" if (firstCell && firstCell.innerText.trim() === '汉语大词典') { // Find the third table cell of the row const thirdCell = row.querySelector('td:nth-child(3)'); // Check if the third cell contains "第6卷" if (thirdCell && thirdCell.innerText.trim().includes('第6卷')) { // Find the second table cell of the row const secondCell = row.querySelector('td:nth-child(2)'); // Check if the second cell contains "第" and "页" if (secondCell && secondCell.innerText.trim().includes('第') && secondCell.innerText.trim().includes('页')) { // Extract the page number from the second cell(- 7983 表示减去前卷页码,+ 29 表示对页码加以调整以适应实际文件) const pageNumber = parseInt(secondCell.innerText.match(/\d+/)[0]) - 7983 + 29; // Generate the page link const pageLink = `file:///D:/hanyudacidian8.pdf#page=${pageNumber}`; // Create the link element and add it to the second cell const link = document.createElement('a'); link.href = pageLink; link.target = '_blank'; link.innerHTML = secondCell.innerText.trim(); secondCell.innerHTML = ''; secondCell.appendChild(link); } } } }); })(); } if (window.location.href.startsWith("http://www.guoxuedashi.net/")) { //《汉语大词典》第7卷 (function() { 'use strict'; // Find all table rows const tableRows = document.querySelectorAll('table tr'); // Loop through all table rows tableRows.forEach(row => { // Find the first table cell of the row const firstCell = row.querySelector('td:first-child'); // Check if the first cell contains "汉语大词典" if (firstCell && firstCell.innerText.trim() === '汉语大词典') { // Find the third table cell of the row const thirdCell = row.querySelector('td:nth-child(3)'); // Check if the third cell contains "第7卷" if (thirdCell && thirdCell.innerText.trim().includes('第7卷')) { // Find the second table cell of the row const secondCell = row.querySelector('td:nth-child(2)'); // Check if the second cell contains "第" and "页" if (secondCell && secondCell.innerText.trim().includes('第') && secondCell.innerText.trim().includes('页')) { // Extract the page number from the second cell(- 9602 表示减去前卷页码,+ 29 表示对页码加以调整以适应实际文件) const pageNumber = parseInt(secondCell.innerText.match(/\d+/)[0]) - 9602 + 29; // Generate the page link const pageLink = `file:///D:/hanyudacidian7.pdf#page=${pageNumber}`; // Create the link element and add it to the second cell const link = document.createElement('a'); link.href = pageLink; link.target = '_blank'; link.innerHTML = secondCell.innerText.trim(); secondCell.innerHTML = ''; secondCell.appendChild(link); } } } }); })(); } if (window.location.href.startsWith("http://www.guoxuedashi.net/")) { //《汉语大词典》第8卷 (function() { 'use strict'; // Find all table rows const tableRows = document.querySelectorAll('table tr'); // Loop through all table rows tableRows.forEach(row => { // Find the first table cell of the row const firstCell = row.querySelector('td:first-child'); // Check if the first cell contains "汉语大词典" if (firstCell && firstCell.innerText.trim() === '汉语大词典') { // Find the third table cell of the row const thirdCell = row.querySelector('td:nth-child(3)'); // Check if the third cell contains "第8卷" if (thirdCell && thirdCell.innerText.trim().includes('第8卷')) { // Find the second table cell of the row const secondCell = row.querySelector('td:nth-child(2)'); // Check if the second cell contains "第" and "页" if (secondCell && secondCell.innerText.trim().includes('第') && secondCell.innerText.trim().includes('页')) { // Extract the page number from the second cell(- 11156 表示减去前卷页码,+ 29 表示对页码加以调整以适应实际文件) const pageNumber = parseInt(secondCell.innerText.match(/\d+/)[0]) - 11156 + 29; // Generate the page link const pageLink = `file:///D:/hanyudacidian8.pdf#page=${pageNumber}`; // Create the link element and add it to the second cell const link = document.createElement('a'); link.href = pageLink; link.target = '_blank'; link.innerHTML = secondCell.innerText.trim(); secondCell.innerHTML = ''; secondCell.appendChild(link); } } } }); })(); } if (window.location.href.startsWith("http://www.guoxuedashi.net/")) { //《汉语大词典》第9卷 (function() { 'use strict'; // Find all table rows const tableRows = document.querySelectorAll('table tr'); // Loop through all table rows tableRows.forEach(row => { // Find the first table cell of the row const firstCell = row.querySelector('td:first-child'); // Check if the first cell contains "汉语大词典" if (firstCell && firstCell.innerText.trim() === '汉语大词典') { // Find the third table cell of the row const thirdCell = row.querySelector('td:nth-child(3)'); // Check if the third cell contains "第9卷" if (thirdCell && thirdCell.innerText.trim().includes('第9卷')) { // Find the second table cell of the row const secondCell = row.querySelector('td:nth-child(2)'); // Check if the second cell contains "第" and "页" if (secondCell && secondCell.innerText.trim().includes('第') && secondCell.innerText.trim().includes('页')) { // Extract the page number from the second cell(- 12517 表示减去前卷页码,+ 29 表示对页码加以调整以适应实际文件) const pageNumber = parseInt(secondCell.innerText.match(/\d+/)[0]) - 12517 + 29; // Generate the page link const pageLink = `file:///D:/hanyudacidian9.pdf#page=${pageNumber}`; // Create the link element and add it to the second cell const link = document.createElement('a'); link.href = pageLink; link.target = '_blank'; link.innerHTML = secondCell.innerText.trim(); secondCell.innerHTML = ''; secondCell.appendChild(link); } } } }); })(); } if (window.location.href.startsWith("http://www.guoxuedashi.net/")) { //《汉语大词典》第10卷 (function() { 'use strict'; // Find all table rows const tableRows = document.querySelectorAll('table tr'); // Loop through all table rows tableRows.forEach(row => { // Find the first table cell of the row const firstCell = row.querySelector('td:first-child'); // Check if the first cell contains "汉语大词典" if (firstCell && firstCell.innerText.trim() === '汉语大词典') { // Find the third table cell of the row const thirdCell = row.querySelector('td:nth-child(3)'); // Check if the third cell contains "第10卷" if (thirdCell && thirdCell.innerText.trim().includes('第10卷')) { // Find the second table cell of the row const secondCell = row.querySelector('td:nth-child(2)'); // Check if the second cell contains "第" and "页" if (secondCell && secondCell.innerText.trim().includes('第') && secondCell.innerText.trim().includes('页')) { // Extract the page number from the second cell(- 13967 表示减去前卷页码,+ 29 表示对页码加以调整以适应实际文件) const pageNumber = parseInt(secondCell.innerText.match(/\d+/)[0]) - 13967 + 29; // Generate the page link const pageLink = `file:///D:/hanyudacidian10.pdf#page=${pageNumber}`; // Create the link element and add it to the second cell const link = document.createElement('a'); link.href = pageLink; link.target = '_blank'; link.innerHTML = secondCell.innerText.trim(); secondCell.innerHTML = ''; secondCell.appendChild(link); } } } }); })(); } if (window.location.href.startsWith("http://www.guoxuedashi.net/")) { //《汉语大词典》第11卷 (function() { 'use strict'; // Find all table rows const tableRows = document.querySelectorAll('table tr'); // Loop through all table rows tableRows.forEach(row => { // Find the first table cell of the row const firstCell = row.querySelector('td:first-child'); // Check if the first cell contains "汉语大词典" if (firstCell && firstCell.innerText.trim() === '汉语大词典') { // Find the third table cell of the row const thirdCell = row.querySelector('td:nth-child(3)'); // Check if the third cell contains "第11卷" if (thirdCell && thirdCell.innerText.trim().includes('第11卷')) { // Find the second table cell of the row const secondCell = row.querySelector('td:nth-child(2)'); // Check if the second cell contains "第" and "页" if (secondCell && secondCell.innerText.trim().includes('第') && secondCell.innerText.trim().includes('页')) { // Extract the page number from the second cell(- 15359 表示减去前卷页码,+ 29 表示对页码加以调整以适应实际文件) const pageNumber = parseInt(secondCell.innerText.match(/\d+/)[0]) - 15359 + 29; // Generate the page link const pageLink = `file:///D:/hanyudacidian11.pdf#page=${pageNumber}`; // Create the link element and add it to the second cell const link = document.createElement('a'); link.href = pageLink; link.target = '_blank'; link.innerHTML = secondCell.innerText.trim(); secondCell.innerHTML = ''; secondCell.appendChild(link); } } } }); })(); } if (window.location.href.startsWith("http://www.guoxuedashi.net/")) { //《汉语大词典》第12卷 (function() { 'use strict'; // Find all table rows const tableRows = document.querySelectorAll('table tr'); // Loop through all table rows tableRows.forEach(row => { // Find the first table cell of the row const firstCell = row.querySelector('td:first-child'); // Check if the first cell contains "汉语大词典" if (firstCell && firstCell.innerText.trim() === '汉语大词典') { // Find the third table cell of the row const thirdCell = row.querySelector('td:nth-child(3)'); // Check if the third cell contains "第12卷" if (thirdCell && thirdCell.innerText.trim().includes('第12卷')) { // Find the second table cell of the row const secondCell = row.querySelector('td:nth-child(2)'); // Check if the second cell contains "第" and "页" if (secondCell && secondCell.innerText.trim().includes('第') && secondCell.innerText.trim().includes('页')) { // Extract the page number from the second cell(- 16801 表示减去前卷页码,+ 29 表示对页码加以调整以适应实际文件) const pageNumber = parseInt(secondCell.innerText.match(/\d+/)[0]) - 16801 + 29; // Generate the page link const pageLink = `file:///D:/hanyudacidian12.pdf#page=${pageNumber}`; // Create the link element and add it to the second cell const link = document.createElement('a'); link.href = pageLink; link.target = '_blank'; link.innerHTML = secondCell.innerText.trim(); secondCell.innerHTML = ''; secondCell.appendChild(link); } } } }); })(); } if (window.location.href.startsWith("https://dict.variants.moe.edu.tw/")) { // 异体字字典自动搜索 (function() { 'use strict'; if (window.location.href.startsWith("https://dict.variants.moe.edu.tw/variants/rbt/query_by_standard.rbt?rbtType=AJAX_INVOKE&componentId=rci_35808733_4&searchedText=")) { window.location.href = `https://dict.variants.moe.edu.tw/variants/rbt/query_by_standard_tiles.rbt?command=backstep`; } if (window.location.href.startsWith("https://dict.variants.moe.edu.tw/variants/rbt/query_by_standard_tiles.rbt?command=backstep")) { setTimeout (function() { var searchBtn = document.querySelector("img[src='images/btn/btn_standard-search.gif']"); // 获取搜索按钮 searchBtn.click(); }, 0); setTimeout (function() { var wordList = document.querySelector("a[id]"); // 获取搜索结果 wordList.click(); }, 2000); } })(); } if (window.location.href.startsWith("https://humanum.arts.cuhk.edu.hk/Lexis/lexi-can/")) { // 粤语审音配词字库自动粘贴搜索 window.onload = function() { 'use strict'; // 获取搜索框和搜索按钮的元素 var searchInput,searchBtn; searchInput = document.querySelector("body > form:nth-child(1) > input[type=text]:nth-child(5)"); searchBtn = document.querySelector("body > form:nth-child(1) > input[type=submit]:nth-child(6)"); if(searchInput){ searchInput.focus(); navigator.clipboard.readText().then(value => { searchInput.value=value; if(searchBtn){ searchBtn.click(); } }); } }; } if (window.location.href.startsWith("https://www.zdic.net/")) { // 汉典 (function() { 'use strict'; // 去广告 const intervalLength = 100; // 间隔时长 const totalTime = 5000; // 总时长5秒 const intervalId = setInterval(function() { // 间隔定时器 let elToRemove = [ document.querySelector("body > main > div.res_c_left.res_s.res_t > div.gc_lslot_a.sticky.res_h.res_s"), // 左(小视图) document.querySelector("body > main > div.res_c_left.res_s.res_t > div.gc_lslot_b.sticky.res_d.res_t.res_s"), // 左(大视图) document.querySelector("body > main > div.zdict > div.topslot_container"), // 上 document.querySelector("#gg_rslot"), // 右 document.querySelector("#gg_rslot2"), // 右下 document.getElementsByClassName("adsbygoogle adsbygoogle-noablate")[1], // 下 document.querySelector("#xxjs > div.content.definitions.xnr > div.mpuslot_b-container"), // 详细解释 document.querySelector("#gg_cslot_1"), // 说文解字 document.querySelector("#gg_cslot_2"), // 末尾 document.querySelector("#gg_lslot_a"), // ts页左 document.querySelector("body > main > div.browse_wrapper > div.topslot_container"), // ts页上 document.querySelector("#gg_bslot_a"), // ts页下 // document.querySelector("#gg_bslot_b"), // ts页方形广告,若去除留空则不美观 document.querySelector("#ad_topslot"), // aboutus页上 document.querySelector("#ad_leftslot_a"), // aboutus页左 document.querySelector("#ad_btmslot_a") // aboutus末尾 ]; elToRemove.forEach(function(el) { if (el) { el.remove(); // 去除广告 } }); }, intervalLength); setTimeout(function() { // 延时定时器 clearInterval(intervalId); }, totalTime); // 定义keyword和各个链接 var keyword = document.querySelector("div.nr-box-header > h2 > span.orth") .textContent.trim(); const noGuoyuDict = (!document.querySelector("a[class='tab'][data-type-block-tab='國語辭典']") && !document.querySelector("a[class='tab'][data-type-block-tab='國語詞典']")); const fanti = [...document.querySelectorAll('span + a')].find(a => a.previousElementSibling?.textContent === '繁体')?.textContent; if (noGuoyuDict && fanti) { keyword = fanti; } // 若无国语辞典又有繁体,则繁体为关键词 let link0 = `http://www.guoxuedashi.net/zidian/so.php?sokeyzi=${keyword}&submit=&kz=1`; let link1 = `https://dict.revised.moe.edu.tw/search.jsp?md=1&word=${keyword}`; let link2 = `https://dict.variants.moe.edu.tw/variants/rbt/query_by_standard.rbt?rbtType=AJAX_INVOKE&componentId=rci_35808733_4&searchedText=${keyword}`; let link3 = `https://humanum.arts.cuhk.edu.hk/Lexis/lexi-can/`; let link4 = `http://www.czyzd.com/search?keyword=${keyword}`; let link5 = `https://www.syndict.com/w2p.php?word=${keyword}&item=hak`; // 选择导航栏,创建并添加多链接元素 const tabsNavigation = document.querySelector("body > main > div.zdict > div.res_c_center > div > div.navigation > div"); const links = document.createElement("links"); // 创建多链接的元素 links.innerHTML = `<a class="tab" href="${link0}" target="_blank">📚国学大师</a>` + (noGuoyuDict ? `<a class="tab" href="${link1}" target="_blank">📙国语辞典</a>` : "") + `<a class="tab" href="${link2}" target="_blank">📕异体字典</a> <a class="tab" href="${link3}" target="_blank">📒粤语字库</a> <a class="tab" href="${link4}" target="_blank">📘潮州字典</a> <a class="tab" href="${link5}" target="_blank">📓客典 </a>`; // 条件 ? 返回值1 : 返回值2 tabsNavigation.appendChild(links); // 添加创建好的元素 // 关键词复制 const yueTab = document.querySelector("body > main > div.zdict > div.res_c_center > div > div.navigation > div > links > a:nth-child(3)"); yueTab.addEventListener("click", function() { let textArea = document.createElement("textarea"); textArea.value = keyword; document.body.appendChild(textArea); textArea.select(); document.execCommand("copy"); console.log(document.execCommand("copy")); document.body.removeChild(textArea); }); // 国语辞典优化 const header = document.querySelector("#gyjs > div.nr-box-header"); // 修改背景色和字体色 header.style.backgroundColor = "rgb(148, 63, 22)"; header.style.color = "rgb(250, 250, 250)"; const entry = document.querySelector("#gyjs > div.nr-box-header > h2"); // 修改对齐方式 entry.style.display = "flex"; entry.style.alignItems = "flex-start"; const dictname = document.querySelector("#gyjs > div.nr-box-header > h2 > span.span.dictname"); // 去除dictname dictname.remove(); const img = ` <a href="${link1}" target="_blank" style="border-bottom: none;"> <img src="https://dict.revised.moe.edu.tw/img/logo1.png" style="width: 300px; max-width: 100%;" alt="國語辭典"> </a>`; // 创建并添加logo entry.innerHTML += img; })(); }