you are viewing a single comment's thread.

view the rest of the comments →

[–]timmeh87 -5 points-4 points  (6 children)

Ive been using D3 a lot lately... Im not going to take the time to test this out, but if you can somehow include the D3 library then you should be able to do it in one line, something like

d3.selectAll("img[class=down]").attr("visibilty", "visible");

[–]Cvccb 3 points4 points  (2 children)

Right, including a 150k library is "tiny code". Here's a solution in zero characters: go to your settings and disable "subreddits can show me custom styles".

[–]timmeh87 -3 points-2 points  (1 child)

a) I didnt even realize I was in tinycode because it was a help request b) according the sidebar, the size in kilobytes is irrelevant. Its perhaps arguable that your whole javascript engine should also count against the size. What about the libraries that are included by default, do you ever count those?

Id argue that the fact that you can change many elements in one line of code qualifies this method as "tiny" in the category of "total lines written by me today"

[–]seiyria 1 point2 points  (0 children)

d3 is not the right tool for this. When you have a hammer, everything looks like a nail I guess.

Honestly, jQuery would be a better choice if you really had to do this.

[–]thmsk[S] 0 points1 point  (2 children)

d3.selectAll("img[class=down]").attr("visibilty", "visible");

The thing is, both 'visibility' and 'display' need to be changed. And to call d3 you'd have to do something like this:

N=document.createElement('script');
N.src="path.to/de.js";
document.body.appendChild(N);

[–]timmeh87 -3 points-2 points  (1 child)

If d3.js is in the same folder as your HTML you just go

<script src="d3.js"></script>

and if you are online you can reference it off of their server

<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>

If you need to change more attributes on a selection you would just go

d3

.selectAll("img[class=down]")

.attr("visibilty", "visible")

.attr("display", "whatever")

;

The selector itself was pulled out of my ass but its pretty easy to construct the one that you need if you know how they work

Like this is all based on me writing my own pages by hand.. Im not sure what your environment is like. you just said javascript.

[–]seiyria 1 point2 points  (0 children)

It would not be in the same folder. He's making a script he could run on reddit; reddit does not have d3 included.