您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Retrieves the original image file from a Tweet or an image hosted by Twitter
当前为
// ==UserScript== // @name Twitter Images Origin Retriever // @version 0.0.1 // @description Retrieves the original image file from a Tweet or an image hosted by Twitter // @author Metal-Mighty // @match https://twitter.com/*/status/* // @match https://pbs.twimg.com/media/* // @grant none // @namespace https://github.com/Metal-Mighty/Twitter-Images-Origin-Retriever // ==/UserScript== (function () { "use strict"; var queryVars = function(str) { return str.replace(/^\?/, '').split('&').map(x => x.split('=')).reduce((a, [k, v]) => { a[k] = v; return a; }, {}); }; // Check if this page contains a single image whose source is also the location. var image = document.getElementsByTagName('img')[0]; var imgSet; var config = { attributes: true, childList: true, subtree: true }; const callback = function(mutationsList, observer) { for (let mutation of mutationsList){ if (mutation.target.className.includes("css-1dbjc4n")) { imgSet = mutation.target.getElementsByTagName('img'); var i; for (i = 0; i < imgSet.length; i++) { var imgSrc = imgSet[i].src; if (imgSrc.includes("https://pbs.twimg.com/media/") && !imgSrc.match(/name=orig/)) { imgSet[i].src = imgSrc.replace(/name=(\w+)/g, 'name=orig'); } } } } } const observer = new MutationObserver(callback); // Start observing the target node for configured mutations observer.observe(document.body, config); if (image && image.getAttribute('src') == location.href) { var imgHref = location.href; var pathname = location.pathname; // Check if we already have the orig modifier if (!imgHref.match(/:orig$/) && !imgHref.match(/name=orig/)) { // Trim modifiers. var idx = pathname.lastIndexOf(':'); if (idx >= 0) pathname = pathname.substr(0, idx); // Check if we need to append the file type. var format = queryVars(location.search).format; if (format && !location.pathname.endsWith(format)) pathname += '.' + format; // Add the modifier. pathname += ':orig'; window.location = pathname; } } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址