Forget the older 2 scripts. They use DOMNodeInserted
which is deprecated.
Merging the InoReader.com scripts is easy. They all use the same selector for waitForKeyElements()
, so merely use if()
statements to determine which regex to apply in the callback function.
Something like this should do it:
// ==UserScript==
// @name InoReader Thumbnail Replacer
// @version 1.0
// @include http://inoreader.com/*
// @include http://www.inoreader.com/*
// @include https://inoreader.com/*
// @include https://www.inoreader.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant GM_addStyle
// ==/UserScript==
waitForKeyElements (
"#reader_pane div.article_full_contents div.article_content a.underlink img",
swapOutThumbnails
);
function swapOutThumbnails (jNode) {
var imgSrc = jNode[0].src;
//-- The necessary regex changes depending on where the images are hosted.
if (/staticflickr/.test (imgSrc) ) {
/*-- Change src from: https://*.staticflickr ... _m.jpg
to: https://*.staticflickr ... _b.jpg
*/
imgSrc = imgSrc.replace (/_m\.jpg$/, "_b.jpg");
}
else if (/amazonaws/.test (imgSrc) ) {
/*-- Change src from: https://*.amazonaws.com ... _6.jpg
to: https://*.amazonaws.com ... _7.jpg
*/
imgSrc = imgSrc.replace (/_6\.jpg$/, "_7.jpg");
}
else if (/fbcdn\-photos/.test (imgSrc) ) {
/*-- Change src from: https://fbcdn-photos- ... _s.jpg
to: https://fbcdn-sphotos- ... _n.jpg
*/
imgSrc = imgSrc.replace (/fbcdn\-photos\-/, "fbcdn-sphotos-");
imgSrc = imgSrc.replace (/_s\.jpg$/, "_n.jpg");
}
else if (/pinimg\.com.*_b\.\w+$/.test (imgSrc) || /pinimg\.com\/192x\//.test (imgSrc) ) {
/*-- Change src from: http://*.pinimg.com/192x/...
to: http://*.pinimg.com/550x/...
*/
imgSrc = imgSrc.replace(/\.com\/192x\//, ".com/550x/");
}
else if (/pinterest\.com.*_b\.\w+$/.test (imgSrc) || /pinterest\.com\/192x\//.test (imgSrc) ) {
/*-- Change src from: http://*.pinterest.com/192x/...
to: http://*.pinterest.com/550x/...
*/
imgSrc = imgSrc.replace(/\.com\/192x\//, ".com/550x/");
}
jNode[0].src = imgSrc;
}
/* Tumblr */
waitForKeyElements (
"#reader_pane div.article_full_contents div.article_content img", swapOutThumbnails2
);
function swapOutThumbnails2 (jNode) {
var imgSrc = jNode[0].src;
if (/tumblr/.test (imgSrc)) {
imgSrc = imgSrc.replace (/_500\.jpg$/, "_1280.jpg");
jNode[0].addEventListener ("error", tumblrImgErrFix, false);
}
jNode[0].src = imgSrc;
}
function tumblrImgErrFix () {
this.src = this.src.replace ("_1280.jpg", "_500.jpg");
console.log ("*** Img Err fix.");
}