您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Prevents images from stretching pages sideways with an optional max width
// ==UserScript== // @name ETI Image Width // @namespace pendevin // @description Prevents images from stretching pages sideways with an optional max width // @include http://endoftheinter.net/inboxthread.php* // @include http://boards.endoftheinter.net/showmessages.php* // @include https://endoftheinter.net/inboxthread.php* // @include https://boards.endoftheinter.net/showmessages.php* // @version 2 // @grant none // @require http://code.jquery.com/jquery-2.1.3.min.js // ==/UserScript== //set this if you want to have a max width for images const MAX_WIDTH=1200; const USE_MAX_WIDTH=false; //ll breaks without noconflict jquery this.$ = this.jQuery = jQuery.noConflict(true); //livelinks compatiblity *JQUERY //calls the function on each message-container in a document, including ones added by livelinks function livelinks(func,extraParams){ if(extraParams==undefined) extraParams=null; //run the function on the message-containers currently on the page $('#u0_1 .message-container').each(function(i,container){ func(container,extraParams); }); //run it on any message-containers added in the future $('#u0_1').on( 'DOMNodeInserted', extraParams, function(e){ if($(e.target).children('.message-container').length){ $(e.target).children('.message-container').each(function(i,container){ func(container,e.data); }); } } ); } //adds a style to a document and returns the style object *JQUERY //css is a string, id is an optional string that determines the object's id function addStyle(css,id){ //create a style var style=$('<style type="text/css">'); //add the css data to it style.html(css); if(id){ //remove any style that has our id $('#'+id).remove(); //give our style the id after removing the other stuff. idk if it matters, but i'm too lazy to find out style.attr('id',id); } //add the style into the head $('head').append(style); //we're outta here return style; } //if the image is a side stretcher, fix it function getSmall(place){ //need all the unloaded images var images=$(place).find('.img-placeholder'); images.each(function(i,img){ img=$(img); var imgWidth=img.width(); //this image is too big if(imgWidth>pageWidth){ var ratio=img.height()/imgWidth; var id=img.attr('id'); var css='\n\ .message #'+id+', .message #'+id+' > img{\n\ max-width:'+pageWidth+'px;\n\ max-height:'+parseInt(pageWidth*ratio)+'px;\n\ }\ '; addStyle(css,'imgWidth_'+id); } }); } //get width of userbar and subtract junk from it var pageWidth=$('.userbar').width(); pageWidth-=6; //if we've got avatars on if($('.userpic').length>0){ pageWidth-=156; } //if we are using a max width, make sure it's not smaller than the page width if(USE_MAX_WIDTH&&pageWidth>MAX_WIDTH){ pageWidth=MAX_WIDTH; } livelinks(getSmall);
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址