Alex_Qwerty
Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
Код: // ==UserScript== // @include * // @exclude https://www.instagram.com/* // ==/UserScript== (function(opera){ document.addEventListener('DOMContentLoaded',function(){ var ScriptName = 'img_srcset.js'; var version = 2; var once = true; var stop = window.jQuery && jQuery.fn.wpexOwlCarousel && jQuery.fn.wpexOwlCarousel.Constructor && jQuery.fn.wpexOwlCarousel.Constructor.Plugins && jQuery.fn.wpexOwlCarousel.Constructor.Plugins.Lazy if (!stop){ function loadSet(selector, attribute) { //selector = selector || 'img[srcset]'; var imgs = document.querySelectorAll(selector); if (once && imgs.length) once = opera.postError(ScriptName+': imgs.length='+imgs.length); for (var i=0; i<imgs.length; i++) { var srcs = imgs[i].getAttribute(attribute); srcs = srcs.split(', '); var size=0,src; for (var ii=0; ii<srcs.length; ii++) { var tmp = srcs[ii].split(' '); var tmpsize = tmp&&tmp[1]&&tmp[1].match(/(\d+)/); tmpsize = tmpsize&&parseInt(tmpsize[1])||0; if (tmpsize>=size){size=tmpsize,src=tmpsize?tmp[0]:tmp} } if (imgs[i].src != src) imgs[i].src = src; } } loadSet('img[srcset]','srcset'); loadSet('img[data-srcset]','data-srcset'); } },false); })(opera) | Код: // ==UserScript== // @include * // @exclude *.deviantart.com/* // @exclude https://yandex.ru/images/* // ==/UserScript== (function(opera){ document.addEventListener('DOMContentLoaded',function(){ var ScriptName = 'fuck_lazy_load.js'; var version = 2; var once = true; function load(selector, attribute, check, remove) { if (!check) { var lazy = document.querySelectorAll(selector); if (lazy.length) opera.postError(ScriptName+': '+selector); for (var i=0; i<lazy.length; i++) { //78 data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 var attr = lazy[i].getAttribute(attribute); if (attr.indexOf(/^data:/)==-1 || attr.len>90) { if(lazy[i].src != attr)lazy[i].src = attr; if (remove) { if (typeof(remove)=='function') { remove(lazy[i]); } else { lazy[i].removeAttribute(attribute); } } } } } } load('img.lazyLoad[data-href]', 'data-href', window.$ && $.lazyLoad, true); load('img.lazyload[data-src]', 'data-src', false, function(img){ img.classList.remove('lazyload'); img.classList.remove('agg-fade-in'); img.removeAttribute('data-src'); }); load('img[data-lazy-src]', 'data-lazy-src'); load('img[data-lazy]', 'data-lazy'); load('img[data-lazySrc]', 'data-lazySrc'); load('img[data-img]', 'data-img', window.$ && $.lazyImage); load('img[data-original]', 'data-original'); load('img[data-echo]', 'data-echo'); load('img[data-src]', 'data-src', false, true); load('img[air-image-src]', 'air-image-src'); load('img.img-ondemand[longdesc]', 'longdesc', window.imgOndemand, function(img){ img.classList.remove('img-ondemand'); img.removeAttribute('longdesc'); }); var lazy = document.querySelectorAll('span[data-lazySrc]>img[src*="placeholder"]'); if (lazy.length) once = opera.postError(ScriptName); for (var i=0; i<lazy.length; i++) lazy[i].src = lazy[i].parentNode.getAttribute('data-lazySrc'); },false); })(opera) | | Всего записей: 2342 | Зарегистр. 09-09-2006 | Отправлено: 12:40 03-09-2018 | Исправлено: Alex_Qwerty, 15:26 10-12-2018 |
|