Twitter new layout Image ORIG

Twitter replace IMAGE with ORIG, add auto remove non image tweets,

当前为 2020-01-27 提交的版本,查看 最新版本

// ==UserScript==
// @name     Twitter new layout Image ORIG
// @description Twitter replace IMAGE with ORIG, add auto remove non image tweets,
// @include     https://twitter.com/*/media
// @include     https://twitter.com/*/likes
// @include     https://twitter.com/*
// @version  1.03
// @grant    none
// @require     https://code.jquery.com/jquery-3.4.1.min.js
// @namespace https://gf.qytechs.cn/users/164357
// ==/UserScript==

//Assign Variable
console.log("Start");
let href = document.location.href;
const sty = `<style>
.new-img {
    width: calc(100% - 20vw);
    border-radius: 10px;
}
</style>
`
$("head").append(sty);
function changeToOrig(link) {
    const n = link.search(/.jpg|.png/)
    let newLink = ""
    if(link.indexOf('jpg')>0){
        newLink = link.substring(0,n) + "?format=jpg&name=orig"
    }
    else if(link.indexOf('png')>0){
        newLink = link.substring(0,n) + "?format=png&name=orig"
    }
    return newLink
}

//End Assign Variable

//Get started

//End started

//Event Handlers Interval
$(document).ready(function(){
    setInterval(function(){
        $(".tweet").each(function(index,value){
                let anchor1 = $(this).find(".js-tweet-text-container")
                let anchor2 = $(this).find(".new-img-container")
                let anchor3 = $(this).find("span.FullNameGroup")
                let anchorImgCon = $(this).find(".AdaptiveMedia")
                let anchorQImageCon = $(this).find(".QuoteMedia-photoContainer")
                if(anchor2.length == 0 && (anchorImgCon.length == 1 || anchorQImageCon.length == 1) ){$(anchor1).after(`<div class="new-img-container"></div>`)}
                if(anchor2.length == 1){
                let photoContainer = $(this).find(".AdaptiveMedia-photoContainer")
                $(photoContainer).each(function(index,value){
                    let img = $(this).attr("data-image-url")
                    let fullImg = changeToOrig(img)
                    $(anchor2).append(`<a href="${fullImg}" target="_blank"><img class="new-img" src="${fullImg}"></img></a>`)
                })
                $(this).find(".AdaptiveMediaOuterContainer").remove()
                if($(this).find(".remove-tweet").length < 1){$(anchor3).before(`<button class="btn remove-tweet">Remove</button>`)}
            }
        })
}, 3000);
setInterval(function(){
    $(".tweet").each(function(index,value){
//        if(href.indexOf("likes") > 0){
            let anchor4 = $(this).find(".AdaptiveMedia")
            let anchor5 = $(this).find(".new-img-container")
            console.log(anchor4);
            if( anchor4.length == 0 && anchor5.length == 0){$(this).remove()}
//        }
    })
}, 3000);
})

//Event Handlers
$("body").on("click",".remove-tweet",function(){
    $(this).closest(".tweet").remove()
})

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址