您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add links to preview PDFs in Google Docs viewer on the current page
当前为
// ==UserScript== // @name PDF Preview Links // @namespace http://cl.thapar.edu/ // @version 0.1 // @description Add links to preview PDFs in Google Docs viewer on the current page // @author You // @match https://cl.thapar.edu/*.php // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // Find all <td> elements with PDF download links var targetElements = document.querySelectorAll('td a[href^="download.php?id="]'); // Loop through each matching element targetElements.forEach(function(targetTd) { // Extract the PDF download link from the existing <a> element var pdfDownloadLink = targetTd.getAttribute('href'); // Construct the Google Docs preview link var googleDocsPreviewLink = 'https://docs.google.com/viewer?url=' + encodeURIComponent("https://cl.thapar.edu/" + pdfDownloadLink); // Create a new link for the preview with a custom class var previewLink = document.createElement('a'); previewLink.href = googleDocsPreviewLink; previewLink.target = '_blank'; previewLink.textContent = 'Preview'; previewLink.className = 'pdf-preview-link'; // Append the new preview link to the target <td> element targetTd.appendChild(document.createTextNode(' | ')); // Separator targetTd.appendChild(previewLink); }); })();