您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Download all images from Pixabay
当前为
// ==UserScript== // @name Download All Images from Pixabay // @namespace http://tampermonkey.net/ // @version 1.1 // @description Download all images from Pixabay // @author @themrsami // @match *://*.pixabay.com/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // Function to download images function downloadImages() { let images = document.images; let imageNames = []; for (let i = 0; i < images.length; i++) { let src = images[i].src; let url = new URL(src); let pathname = url.pathname.substring(1); let parts = pathname.split('/'); let filename = parts[parts.length - 1]; let [name, extension] = filename.split('.'); if (extension === 'png' || extension === 'jpg' || extension === 'jpeg') { name = name.split('_')[0]; filename = `${name}.${extension}`; imageNames.push(filename); } } imageNames = [...new Set(imageNames)]; let baseUrl = 'https://pixabay.com/images/download/'; for (let imageName of imageNames) { let downloadUrl = baseUrl + imageName; fetch(downloadUrl) .then(response => { let contentLength = response.headers.get('Content-Length'); if (contentLength !== null) { let sizeInBytes = Number(contentLength); let sizeInKB = sizeInBytes / 1024; if (sizeInKB > 100) { return response.blob(); } else { throw new Error('Image is less than 100 KB'); } } else { throw new Error('Could not determine image size'); } }) .then(blob => { let url = window.URL.createObjectURL(blob); let a = document.createElement('a'); a.href = url; a.download = imageName; document.body.appendChild(a); a.click(); document.body.removeChild(a); }) .catch(error => console.error('Error:', error)); } alert('Images are being downloaded!'); } // Create a card let card = document.createElement('div'); card.style.position = 'fixed'; card.style.top = '10px'; card.style.left = '10px'; card.style.zIndex = '9999'; card.style.padding = '20px'; card.style.borderRadius = '5px'; card.style.backgroundColor = '#333'; card.style.boxShadow = '0 2px 5px rgba(0, 0, 0, 0.3)'; card.style.color = '#fff'; card.style.width = '500px'; card.style.transition = '0.3s'; // Create tabs let tabs = document.createElement('div'); tabs.style.display = 'flex'; tabs.style.justifyContent = 'space-between'; tabs.style.marginBottom = '20px'; // Create tab labels let tabLabels = ['Home', 'Instructions', 'Author Info']; // Create tabs let tabElements = tabLabels.map(label => { let tab = document.createElement('div'); tab.innerHTML = label; tab.style.cursor = 'pointer'; tab.style.padding = '10px'; tab.style.backgroundColor = '#555'; tab.style.borderRadius = '5px'; tab.style.transition = '0.3s'; tab.onmouseover = function() { this.style.backgroundColor = '#777'; }; tab.onmouseout = function() { this.style.backgroundColor = (tab === activeTab) ? '#777' : '#555'; }; tab.addEventListener('click', () => setActiveTab(tab)); return tab; }); // Set active tab let activeTab = tabElements[0]; activeTab.style.backgroundColor = '#777'; // Add tabs to the tabs container tabElements.forEach(tab => tabs.appendChild(tab)); // Create content container let content = document.createElement('div'); // Create download button let button = document.createElement('button'); button.innerHTML = 'Download All Images'; button.style.padding = '10px 20px'; button.style.fontSize = '16px'; button.style.borderRadius = '5px'; button.style.border = 'none'; button.style.backgroundColor = '#4CAF50'; button.style.color = 'white'; button.style.cursor = 'pointer'; // Add click event listener to the button button.addEventListener('click', downloadImages); // Create instructions text let instructions = document.createElement('p'); instructions.innerHTML = ` <h3>Enable Parallel Downloading in Chrome Flags</h3> <ul> <br> <li>Open Chrome and navigate to <br><code>chrome://flags/#enable-parallel-downloading</code></li><br> <li>Select <strong>Enabled</strong> from the dropdown next to "Enable parallel downloading"</li><br> <li>Click on the <strong>Relaunch</strong> button at the bottom to apply the changes</li><br> </ul> `; // Create author info text let authorInfo = document.createElement('p'); authorInfo.innerHTML = ` <h3 style="text-align: center;">Author Information</h3> <div style="display: flex; gap: 10px; justify-content: center;"> <a href="https://www.youtube.com/@themistersami" target="_blank" rel="noopener noreferrer"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="40" width="40" version="1.1" id="Layer_1" viewBox="0 0 461.001 461.001" xml:space="preserve"> <g> <path style="fill:#F61C0D;" d="M365.257,67.393H95.744C42.866,67.393,0,110.259,0,163.137v134.728 c0,52.878,42.866,95.744,95.744,95.744h269.513c52.878,0,95.744-42.866,95.744-95.744V163.137 C461.001,110.259,418.135,67.393,365.257,67.393z M300.506,237.056l-126.06,60.123c-3.359,1.602-7.239-0.847-7.239-4.568V168.607 c0-3.774,3.982-6.22,7.348-4.514l126.06,63.881C304.363,229.873,304.298,235.248,300.506,237.056z"/> </g> </svg> </a> <a href="https://www.instagram.com/themrsami" target="_blank" rel="noopener noreferrer"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="40" width="40" version="1.1" id="Layer_1" viewBox="0 0 551.034 551.034" xml:space="preserve"> <g id="XMLID_13_"> <linearGradient id="XMLID_2_" gradientUnits="userSpaceOnUse" x1="275.517" y1="4.5714" x2="275.517" y2="549.7202" gradientTransform="matrix(1 0 0 -1 0 554)"> <stop offset="0" style="stop-color:#E09B3D"/> <stop offset="0.3" style="stop-color:#C74C4D"/> <stop offset="0.6" style="stop-color:#C21975"/> <stop offset="1" style="stop-color:#7024C4"/> </linearGradient> <path id="XMLID_17_" style="fill:url(#XMLID_2_);" d="M386.878,0H164.156C73.64,0,0,73.64,0,164.156v222.722 c0,90.516,73.64,164.156,164.156,164.156h222.722c90.516,0,164.156-73.64,164.156-164.156V164.156 C551.033,73.64,477.393,0,386.878,0z M495.6,386.878c0,60.045-48.677,108.722-108.722,108.722H164.156 c-60.045,0-108.722-48.677-108.722-108.722V164.156c0-60.046,48.677-108.722,108.722-108.722h222.722 c60.045,0,108.722,48.676,108.722,108.722L495.6,386.878L495.6,386.878z"/> <linearGradient id="XMLID_3_" gradientUnits="userSpaceOnUse" x1="275.517" y1="4.5714" x2="275.517" y2="549.7202" gradientTransform="matrix(1 0 0 -1 0 554)"> <stop offset="0" style="stop-color:#E09B3D"/> <stop offset="0.3" style="stop-color:#C74C4D"/> <stop offset="0.6" style="stop-color:#C21975"/> <stop offset="1" style="stop-color:#7024C4"/> </linearGradient> <path id="XMLID_81_" style="fill:url(#XMLID_3_);" d="M275.517,133C196.933,133,133,196.933,133,275.516 s63.933,142.517,142.517,142.517S418.034,354.1,418.034,275.516S354.101,133,275.517,133z M275.517,362.6 c-48.095,0-87.083-38.988-87.083-87.083s38.989-87.083,87.083-87.083c48.095,0,87.083,38.988,87.083,87.083 C362.6,323.611,323.611,362.6,275.517,362.6z"/> <linearGradient id="XMLID_4_" gradientUnits="userSpaceOnUse" x1="418.306" y1="4.5714" x2="418.306" y2="549.7202" gradientTransform="matrix(1 0 0 -1 0 554)"> <stop offset="0" style="stop-color:#E09B3D"/> <stop offset="0.3" style="stop-color:#C74C4D"/> <stop offset="0.6" style="stop-color:#C21975"/> <stop offset="1" style="stop-color:#7024C4"/> </linearGradient> <circle id="XMLID_83_" style="fill:url(#XMLID_4_);" cx="418.306" cy="134.072" r="34.149"/> </g> </svg> </a> </div> `; // Add content to the content container content.appendChild(button); content.appendChild(instructions); content.appendChild(authorInfo); // Add content to the card card.appendChild(tabs); card.appendChild(content); // Append the card to the body document.body.appendChild(card); // Helper function to set active tab function setActiveTab(tab) { activeTab.style.backgroundColor = '#555'; tab.style.backgroundColor = '#777'; activeTab = tab; updateContent(); } // Helper function to update content based on active tab function updateContent() { button.style.display = (activeTab === tabElements[0]) ? 'block' : 'none'; instructions.style.display = (activeTab === tabElements[1]) ? 'block' : 'none'; authorInfo.style.display = (activeTab === tabElements[2]) ? 'block' : 'none'; } // Initialize content based on the active tab updateContent(); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址