针对火狐浏览器:去除火狐自带缩放(改为默认100%大小自动居中) | 可拖拽 | 以鼠标中心缩放 | 限定最小缩放(图片大小和屏幕大小较小值的50%) | 左上角显示缩放比例,点击还原 | 可旋转、水平翻转 | 图片加载完毕后闪烁一次
当前为
// ==UserScript==
// @icon https://github.com/favicon.ico
// @name 【自用】浏览器看图 for FireFox
// @namespace Violentmonkey Scripts
// @match http*://*/*.jpg
// @match http*://*/*.jpeg
// @match http*://*/*.png
// Homepage URL https://greasyfork.org/zh-CN/scripts/428791-%E8%87%AA%E7%94%A8-jpg
// 更新页面 https://greasyfork.org/zh-CN/scripts/428791/versions/new
// @grant none
// @version 2021.07.19
// @author heckles
// @description 针对火狐浏览器:去除火狐自带缩放(改为默认100%大小自动居中) | 可拖拽 | 以鼠标中心缩放 | 限定最小缩放(图片大小和屏幕大小较小值的50%) | 左上角显示缩放比例,点击还原 | 可旋转、水平翻转 | 图片加载完毕后闪烁一次
// ==/UserScript==
if (document.getElementById("browser-app") || document.getElementById("masthead")) { //这两个元素,有一个是true,就往下执行
setInterval(function () { //间隔执行
if (window.location.href.indexOf("watch?v=") < 0) { //如果网址不匹配
return false; //就不执行
}
if (document.getElementById("meta-contents") && document.getElementById("punisher") === null) { //网址匹配的话,punisher没有被添加
StartJS(); //就执行函数,添加punisher
}
}, 1000); //间隔时间1000毫秒
return;
}
function StartJS() {
const btncss = `
color: #fff;
text-transform: uppercase;
padding: 2px 6px;
background-color: transparent;
border-color: transparent;
`
//开始添加按钮
var buttonDiv = document.createElement("span");
buttonDiv.id = "punisher";
buttonDiv.style.width = "100%";
buttonDiv.style.marginTop = "3px";
buttonDiv.style.padding = "10px 0";
var addButtonV = document.createElement("button");
var addButtonA = document.createElement("button");
addButtonV.appendChild(document.createTextNode("视频名"));
addButtonA.appendChild(document.createTextNode("音频名"));
addButtonV.style.cssText = btncss;
addButtonA.style.cssText = btncss;
buttonDiv.appendChild(addButtonV);
buttonDiv.appendChild(addButtonA);
var targetElement = document.querySelectorAll("[id='info-text']"); //youtube故意的,很多元素id重复,这里够绝,直接全选中,然后按class筛,再加
if (targetElement) {
for (var i = 0; i < targetElement.length; i++) {
if (targetElement[i].className.indexOf("style-scope ytd-video-primary-info-renderer") > -1) {
targetElement[i].appendChild(buttonDiv);
}
}
}
//创建一个input,但是不显示(通过移位),作为复制的中介
var nMInput = document.createElement('input');
nMInput.style.cssText = "position:absolute; top:-200px;"; //火狐实测隐藏的话不能选,oInput.style.display='none';
document.body.appendChild(nMInput);
//先生成文件名
var nM_V = '"' + document.querySelector("#container h1 yt-formatted-string").innerText + ' - DASH_V' + '"' + '.mp4';
var nM_A = '"' + document.querySelector("#container h1 yt-formatted-string").innerText + ' - DASH_A' + '"' + '.m4a';
//IDM下载命令行所需
const ds1 = `"D:\\Programs\\Internet Download Manager"\\idman.exe /n /d "`
const ds2 = `" /f `
//按钮加event //shadowroot的mode必须是open,否则没有ShadowDOM
addButtonV.onclick = function () {
var xroot = document.getElementById("hahahazijijiade");
//console.log(xroot.shadowRoot.children[0]);
var linkss = xroot.shadowRoot.children[0].children[2].children[1].children[1];
var ku = linkss.querySelectorAll("a");
if (ku) {
for (var i = 0; i < ku.length; i++) {
if (linkss.children[i].innerText.indexOf("1080p: video/mp4") > -1) { //用=0就不行,用>-1就行...,如果没有,就是-1
nMInput.value = ds1 + linkss.children[i].href + ds2 + nM_V;
console.log(nMInput.value);
}
}
}
nMInput.select(); // 选择对象
document.execCommand("Copy"); // 执行浏览器复制命令,火狐里面这个command只能是用户触发,不能自动
};
//按钮加event //shadowroot的mode必须是open,否则没有ShadowDOM
addButtonA.onclick = function () {
var xroot = document.getElementById("hahahazijijiade");
var linkss = xroot.shadowRoot.children[0].children[2].children[1].children[1];
var ku = linkss.querySelectorAll("a");
if (ku) {
for (var i = 0; i < ku.length; i++) {
if (linkss.children[i].innerText.indexOf("audio/mp4") > -1) { //用=0就不行,用>-1就行...,如果没有,就是-1
nMInput.value = ds1 + linkss.children[i].href + ds2 + nM_A;
console.log(nMInput.value);
}
}
}
nMInput.select(); // 选择对象
document.execCommand("Copy"); // 执行浏览器复制命令,火狐里面这个command只能是用户触发,不能自动
};
}