Add LA Times and rework data_srcset.js to use srcset attribute
This commit is contained in:
parent
e4dfd0f6c0
commit
52202fb45c
|
@ -4,15 +4,23 @@
|
||||||
// @grant none
|
// @grant none
|
||||||
// @match https://kotaku.com/*
|
// @match https://kotaku.com/*
|
||||||
// @match https://*.gizmodo.com/*
|
// @match https://*.gizmodo.com/*
|
||||||
|
// @match https://www.latimes.com/*
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
|
function fixSrcset(element) {
|
||||||
|
let srcSet = element.getAttribute('data-srcset');
|
||||||
|
console.log(srcSet);
|
||||||
|
if (srcSet) {
|
||||||
|
element.setAttribute('srcset', srcSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function fixImages() {
|
function fixImages() {
|
||||||
for (let img of document.getElementsByTagName('img')) {
|
for (let img of document.getElementsByTagName('img')) {
|
||||||
let srcSet = img.getAttribute('data-srcset');
|
fixSrcset(img);
|
||||||
if (srcSet) {
|
}
|
||||||
let imgUrl = srcSet.split(', ').slice(-1)[0].split(' ')[0];
|
for (let img of document.getElementsByTagName('source')) {
|
||||||
img.setAttribute('src', imgUrl);
|
fixSrcset(img);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue