Tampermonkey help

Kinja'd!!! "Yowen - not necessarily not spaghetti and meatballs" (yowen)
12/18/2013 at 16:09 • Filed to: None

Kinja'd!!!1 Kinja'd!!! 11

So all of oppo's images have become broken for me...

like this link:
!!!error: Indecipherable SUB-paragraph formatting!!!

But when i remove the first portion:
!!!error: Indecipherable SUB-paragraph formatting!!!

Leaving only:
!!!error: Indecipherable SUB-paragraph formatting!!!

the images work again, does anyone have enough know-how with tampermonkey or know another way to do this so i can see images again?

edit: I had to remove http:// from everywhere to make this show up properly.


DISCUSSION (11)


Kinja'd!!! BJ > Yowen - not necessarily not spaghetti and meatballs
12/18/2013 at 16:52

Kinja'd!!!0

I don't think this is Tampermonkey - I've seen this a number of times over the last few days. I think the back-end is serving up bad images, and after a refresh or two, they come back correctly.


Kinja'd!!! BJ > BJ
12/18/2013 at 16:53

Kinja'd!!!0

In any case, I'm not changing any image URLs with my plugin. I just remove the forced resizing that makes them so small.


Kinja'd!!! Yowen - not necessarily not spaghetti and meatballs > BJ
12/18/2013 at 17:02

Kinja'd!!!0

I need tampermonkey to do what I described above (remove the cloudinary bit form the url) because cloudinary is blocked at my work.


Kinja'd!!! BJ > Yowen - not necessarily not spaghetti and meatballs
12/18/2013 at 17:03

Kinja'd!!!0

Ahhh, I see... I though you were referring to my userscript breaking stuff. I should have some free time tonight to write up a little piece of code for you, but no promises 'cause the wife wants me to make meatballs.


Kinja'd!!! Yowen - not necessarily not spaghetti and meatballs > BJ
12/19/2013 at 08:09

Kinja'd!!!0

Yeah I'd really appreciate if you could make me something that would take the cloudinary portion out of the image files, I'm not getting my oppo vehicles, cats, dogs and nsfw fix, lol.


Kinja'd!!! Yowen - not necessarily not spaghetti and meatballs > BJ
12/19/2013 at 09:18

Kinja'd!!!0

I tried using this:
http://userscripts.org/scripts/show/2…

but no luck


Kinja'd!!! Yowen - not necessarily not spaghetti and meatballs > BJ
12/19/2013 at 11:09

Kinja'd!!!0

WOOHOO I feel like a golden god right now, it could probably be done more elegantly, but this is what I did:

// ==UserScript==

// @name Remove Cloudinary from Oppo

// @namespace http://jalopnik.com

// @version 0.1

// @description If it's blocked at your work

// @include http://*.jalopnik.com*

// @copyright 2012+, You

// ==/UserScript==

var img=document.evaluate("//img", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

for(i = 0; i < img.snapshotLength; i++) {

tmp = img.snapshotItem(i);

if(tmp.src.indexOf(' http://res.cloudinary.com/gawker-media/i… ' != -1)){

tmp.src = tmp.src.replace(' http://res.cloudinary.com/gawker-media/i… ', '');

}

}

var img=document.evaluate("//img", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

for(i = 0; i < img.snapshotLength; i++) {

tmp = img.snapshotItem(i);

if(tmp.src.indexOf(' http://res.cloudinary.com/gawker-media/i… ' != -1)){

tmp.src = tmp.src.replace(' http://res.cloudinary.com/gawker-media/i… ', '');

}

}

var img=document.evaluate("//img", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

for(i = 0; i < img.snapshotLength; i++) {

tmp = img.snapshotItem(i);

if(tmp.src.indexOf(' http://res.cloudinary.com/gawker-media/i… ' != -1)){

tmp.src = tmp.src.replace(' http://res.cloudinary.com/gawker-media/i… ', '');

}

}


Kinja'd!!! BJ > Yowen - not necessarily not spaghetti and meatballs
12/19/2013 at 11:54

Kinja'd!!!0

Nicely done. I'm not that good with the DOM and XPath business, so I would have gone the jQuery route. I may still put something together as an example, if I have the time...


Kinja'd!!! Yowen - not necessarily not spaghetti and meatballs > BJ
12/19/2013 at 13:55

Kinja'd!!!0

Would you happen to know how to make this script run another time maybe 3 seconds later, as this runs before comments appear. So if I make it run another time 3 seconds later it'll get whatevers in the comments.


Kinja'd!!! BJ > Yowen - not necessarily not spaghetti and meatballs
12/19/2013 at 14:44

Kinja'd!!!0

Wrap your script in a function:

//Userscript stuff here...

function rewriteImageUrls() {

// your code

}

rewriteImageUrls(); //run immediately

setTimeout(rewriteImageUrls, 3000); //run one more time in 3 seconds


Kinja'd!!! Yowen - not necessarily not spaghetti and meatballs > BJ
12/19/2013 at 14:49

Kinja'd!!!0

awesome thank you! I will try it out.