您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
添加一个图标按钮来打开特定网页,带有当前页面的参数
当前为
- // ==UserScript==
- // @name QuickDownloader
- // @namespace http://tampermonkey.net/
- // @version 0.4
- // @description 添加一个图标按钮来打开特定网页,带有当前页面的参数
- // @match *://*.amazon.com/*
- // @match *://*.amazon.co.uk/*
- // @match *://*.amazon.de/*
- // @match *://*.amazon.fr/*
- // @match *://*.amazon.it/*
- // @match *://*.amazon.es/*
- // @match *://*.amazon.ca/*
- // @match *://*.amazon.co.jp/*
- // @match *://*.amazon.cn/*
- // @match *://*.amazon.in/*
- // @match *://*.amazon.com.br/*
- // @match *://*.amazon.com.mx/*
- // @match *://*.amazon.com.au/*
- // @match *://*.amazon.nl/*
- // @match *://*.amazon.sg/*
- // @grant GM_addStyle
- // @require https://kit.fontawesome.com/4c29a4a2e7.js
- // @license MIT
- // ==/UserScript==
- (function() {
- 'use strict';
- // 添加 Font Awesome 样式
- GM_addStyle(`
- @import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css');
- `);
- // 创建按钮
- function createButton() {
- var button = document.createElement('button');
- button.innerHTML = '<i class="fas fa-download"></i>';
- button.title = '下载书籍'; // 添加tooltip
- button.style.top = '10px';
- button.style.right = '10px';
- button.style.zIndex = '9999';
- button.style.background = 'none';
- button.style.border = 'none';
- button.style.fontSize = '24px';
- button.style.color = '#0066c0'; // 修改为蓝色
- button.style.cursor = 'pointer';
- return button;
- }
- // 从页面提取参数
- function extractParams() {
- var productTitle = document.querySelector('#productTitle')?.textContent.trim();
- return encodeURIComponent(productTitle)
- }
- // 构建目标URL
- function buildTargetUrl(params) {
- return `https://zh.singlelogin.re/s/${params}?`;
- }
- // 插入按钮到指定位置
- function insertButton(button) {
- // 这里假设我们要将按钮插入到一个 ID 为 'product-title' 的元素后面
- var targetElement = document.querySelector('#productTitle');
- if (targetElement) {
- targetElement.parentNode.insertBefore(button, targetElement.nextSibling);
- } else {
- console.error('Target element for button insertion not found');
- }
- }
- // 主函数
- function main() {
- var button = createButton();
- button.addEventListener('click', function() {
- var params = extractParams();
- var targetUrl = buildTargetUrl(params);
- window.open(targetUrl, '_blank');
- });
- insertButton(button);
- }
- // 运行主函数
- main();
- })();