PDA

View Full Version : Updated spoiler tag removal and image resize?



Winter_Wolf
2014-03-31, 12:37 PM
Before the update, I'd gotten hold of a lovely little bit of code that I could put into a bookmark which automatically stripped out spoiler tags and resized large images to be small enough to fit the screen. It still works for other sites, but not the newly updated Giantitp.com forums.

Since I got prompt help from some kindly soul on this forum last time I asked, I'm curious if anyone's rushed to fill that particular niche again.

Because I hate rampant spoiler tags and getting stretch-bombed by images hiding behind spoiler tags.

Taet
2014-03-31, 01:08 PM
Please share this code! The Demotivators thread needs it! :smallbiggrin:

Winter_Wolf
2014-03-31, 01:33 PM
Please share this code! The Demotivators thread needs it! :smallbiggrin:

That's the problem. The code I have doesn't work with the new forum. And yep, the demotivator thread (among other image threads here) are the very reason I wanted the code in the first place. The nifty little thing still does work on other websites that I go to, so it's still got uses. I actually got it from some other user when I asked about it in some thread many moons ago. I haven't even got a clue where the original thread went or I'd just point you directly at it. Let me say this again: it doesn't work for me now, so don't be surprised if it won't work for you. If it does, mazal tov.

Keeping in mind that this does not work (for me anyway) on the new forums here, and also keeping in mind that when I originally got the code I just copy/pasted it so if anything changed between then and now I'd have no idea:
javascript:(function()%20{%20var%20a%20=%20documen t.getElementsByTagName('div');%20for%20(var%20i%20 =%200%20;%20i%20<%20a.length%20;%20i++)%20{%20if%20(a[i].className%20==%20'spoiler')%20{%20a[i].style.display%20=%20'block';%20a[i].className%20=%20'';%20}%20else%20if%20(a[i].className%20==%20'pre-spoiler')%20{%20a[i].style.display%20=%20'none';%20}}%20a%20=%20docume nt.getElementsByTagName('img');%20for%20(i%20=%200 %20;%20i%20<%20a.length%20;%20i++)%20{%20a[i].style.maxWidth%20=%20'600px';%20}})();

factotum
2014-03-31, 02:49 PM
I think the new forum automatically resizes images to fit, so you don't get stretch-bombed? It certainly did on some images in a spoiler I saw earlier, no idea if it also does it for non-spoilered images.

Winter_Wolf
2014-03-31, 04:22 PM
I'm still left with the issue of spoiler tags on text. As I don't really give a damn if I get spoiled for a TV show/movie/novel/whatever plot (in fact I expect it if it's a thread about a show/film/novel/whatever), it's just easier and faster to at least strip out all the the spoiler tags. 'Cause you know, some people just insist that you simply must have spoiler tags within even threads that clearly state "SPOILERS INSIDE". I've seen it happen. Plus the little script thing lets other spoil to their heart's content but I don't have to deal with the irritation on my end as a reader. Sometimes the spoiler tags are nice, other times they're just the deciding factor between following a thread and having better things to do.

Clicking the "no more spoilers" bookmark is my default action any time I see a spoiler tag anymore. Well unless there are "spoilers for context" things in the thread. I'm of the mind that if it's not funny without the "proper context" then it's probably not that funny.

Prime32
2014-04-02, 09:19 PM
Let's space that code properly first.

javascript:(function() {
var a = document.getElementsByTagName('div');
for (var i = 0 ; i < a.length ; i++) {
if(a[i].className == 'spoiler') {
a[i].style.display = 'block';
a[i].className = '';
} else if (a[i].className == 'pre-spoiler') {
a[i].style.display = 'none';
}
}
a = document.getElementsByTagName('img');
for (i = 0 ; i < a.length ; i++) {
a[i].style.maxWidth = '600px';
}
})();

Looking at the source code of the page, GitP's current spoiler blocks don't have the class "spoiler" (instead everything is done through style attributes :smallconfused:) and thus aren't targeted. It's a bit crude (as in, it'll break if the look of the spoilers changes), but maybe something like this?


javascript:(function() {
var a = document.getElementsByTagName('div');
for (var i=0; i<a.length; i++) {
if(a[i].className == 'quotecontent') {
a[i].style.display = 'block';
a[i].className = '';
} else if (a[i].getAttribute('style') == 'text-transform: none; border-bottom: medium none; padding: 3px 5px 3px 0px; display: block;') {
a[i].style.display = 'none';
}
}
a = document.getElementsByTagName('img');
for (i=0; i<a.length; i++) {
a[i].style.maxWidth = '600px';
}
})();

javascript:(function()%20{var%20a%20=%20document.g etElementsByTagName('div');%20for%20(var%20i=0;%20 i<a.length%20;%20i++)%20{%20if(a[i].className%20==%20'quotecontent')%20{%20a[i].style.display%20=%20'block';%20a[i].className%20=%20'';%20}%20else%20if%20(a[i].getAttribue('style')%20==%20'text-transform:%20none;%20border-bottom:%20medium%20none;%20padding:%203px%205px%20 3px%200px;%20display:%20block;')%20{a[i].style.display%20=%20'none';}}%20a%20=%20document. getElementsByTagName('img');%20for%20(i=0;%20i<a.length;%20i++)%20{%20a[i].style.maxWidth%20=%20'600px';}})();

Winter_Wolf
2014-04-02, 10:12 PM
I hope you weren't asking me. (I know you weren't actually asking me.) My sum total knowledge of code is "might as well be magic". Even though I viewed page source, all that I really got out of it was, "yep, that's a whole lot of formatted text, numbers, and symbols." :smallfrown:

That said, none of those worked for me. Well, the first one worked once as far as stripping out spoiler tag, but also deleted anything that was inside the spoiler tag. And then it stopped working completely. The second worked not at all for me. My test subjects were this thread and the demotivator thread in the Roleplaying Games forum.

Excession
2014-04-06, 11:10 PM
If you're using Firefox, you can download the "Stylish" extension and use it to force all spoilers open. The CSS to do that is:

@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document domain("giantitp.com") {
div.quotecontent > div {
display: block !important;
}
}
With that turned on, all spoilers will be start off open, and cannot be closed.

Winter_Wolf
2014-04-07, 01:49 AM
Well hey that works pretty nicely. It'll take a little getting used to (as it's automated instead of manual), but it does more or less the same thing as the other spoiler remover bookmark/code.

Danke!

Deadly
2014-04-07, 02:51 AM
If you still want the bookmark solution instead of using the plugin, here's a quick update of the code which should work. I removed the image rescaling since the forum handles that now


javascript:(function() {
var a = document.getElementsByTagName('div'); var b ;
for (var i = 0 ; i < a.length ; i++) {
if(a[i].className == 'quotecontent') {
b = a[i].getElementsByTagName('div') ;
for (var j = 0 ; j < b.length ; j++) {
b[j].style.display = 'block';
}
}
}
})();

As a single line

javascript:(function() { var a = document.getElementsByTagName('div'); var b ; for (var i = 0 ; i < a.length ; i++) { if(a[i].className == 'quotecontent') { b = a[i].getElementsByTagName('div') ; for (var j = 0 ; j < b.length ; j++) { b[j].style.display = 'block'; }}}})();

Winter_Wolf
2014-04-07, 08:34 PM
I just want you all to know you're Awesome. I'm keeping both versions, because I'm sure they'll both be useful to me now and in future.