try to take over the world!
当前为
// ==UserScript==
// @name MaGuitarDownloadImage
// @namespace http://tampermonkey.net/
// @version 0.3
// @description try to take over the world!
// @author You
// @match https://www.zeczec.com/projects/mashushu-rock/updates/*
// @grant none
// @require http://code.jquery.com/jquery-1.9.1.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/downloadjs/1.4.8/download.js
// @run-at document-end
// ==/UserScript==
(function() {
$(document).ready(function(){
var images = GetImages();
$("label:contains('搜尋')").parent().prepend("<input id=\"downloadImgs\" type=\"button\" value=\"下載教學圖片\">");
var title = $('h3:contains("熱門單曲")');
title.append("<input id=\"copyTitle\" type=\"button\" value=\"複製標題\">");
$("#downloadImgs").click(function(){
downloadAll(images);
});
$("#copyTitle").click(function(){
copyTitle();
});
});
})();
function GetImages(){
var result = [];
$("img").each(function(index, element) {
if($(element).attr("src").indexOf("amazonaws") != -1){
result.push($(element).attr("src"));
}
});
return result;
}
String.prototype.filename=function(extension){
var s= this.replace(/\\/g, '/');
s= s.substring(s.lastIndexOf('/')+ 1);
return extension? s.replace(/[?#].+$/, ''): s.split('.')[0];
}
function downloadAll(images) {
$(images).each(function(index, element) {
forceDownload(element,element.filename());
});
}
function forceDownload(url, fileName){
var downloadUrl = 'https://cors-anywhere.herokuapp.com/' + url;
var xhr = new XMLHttpRequest();
xhr.open("GET", downloadUrl, true);
xhr.responseType = "blob";
xhr.onload = function(){
var urlCreator = window.URL || window.webkitURL;
var imageUrl = urlCreator.createObjectURL(this.response);
var tag = document.createElement('a');
tag.href = imageUrl;
tag.download = fileName;
document.body.appendChild(tag);
tag.click();
document.body.removeChild(tag);
}
xhr.send();
}
function copyTitle(){
var title = $('h3:contains("熱門單曲")').text();
var myRegexp = /【熱門單曲】(.*)\(/g;
var match = myRegexp.exec(title);
copyToClipboard(match[1]);
}
function copyToClipboard(text) {
if (window.clipboardData && window.clipboardData.setData) {
// IE specific code path to prevent textarea being shown while dialog is visible.
return clipboardData.setData("Text", text);
} else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
var textarea = document.createElement("textarea");
textarea.textContent = text;
textarea.style.position = "fixed"; // Prevent scrolling to bottom of page in MS Edge.
document.body.appendChild(textarea);
textarea.select();
try {
return document.execCommand("copy"); // Security exception may be thrown by some browsers.
} catch (ex) {
console.warn("Copy to clipboard failed.", ex);
return false;
} finally {
document.body.removeChild(textarea);
}
}
}
document.querySelector("#copy").onclick = function() {
var result = copyToClipboard(new Date().toString());
console.log("copied?", result);
};
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址