在查看大图时会在右侧显示一个按钮。点击按钮就可以在新页面查看和保存图片。
// ==UserScript==
// @name 在新页面打开twitter的图片
// @name:en open twitter image in new tab
// @namespace https://saber.love/?p=3967
// @version 0.3
// @description 在查看大图时会在右侧显示一个按钮。点击按钮就可以在新页面查看和保存图片。
// @description:en On you view big image, you can view and save image in new tab.
// @author xuejianxianzun
// @include *://twitter.com*
// @icon https://twitter.com/favicon.ico
// @run-at document-end
// ==/UserScript==
let t_img_wrap = document.querySelector('.Gallery-media');
let t_img_url;
if (t_img_wrap) {
let t_img_down_button = document.createElement('div');
t_img_down_button.innerHTML = 'open image';
t_img_down_button.setAttribute('style', 'display:inline-block;visibility:hidden;padding:5px 7px;position: fixed;right: 0;top: 30%;z-index: 9999;background:#1EA1F2;color:#fff;cursor: pointer;');
document.body.appendChild(t_img_down_button);
t_img_down_button.addEventListener('click', function () {
window.open(t_img_url);
});
setInterval(function () {
let t_img_element = document.querySelector('.Gallery-media .media-image');
if (t_img_element && t_img_element.nodeName !== 'IMG') { // 有些页面上面的选择器就是图片,有些是图片包含在上个选择器里面
t_img_element = t_img_element.querySelector('img');
if (t_img_element === null) { // 如果没有这个元素
return false;
}
}
if (t_img_element && getComputedStyle(t_img_wrap)['display'] === 'block') {
t_img_url = t_img_element.src.replace('large','orig');
t_img_down_button.style.visibility = 'visible';
} else {
t_img_down_button.style.visibility = 'hidden';
}
}, 400);
}
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址