Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • September 29, 2016, 11:52:08 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: Greasemonkey script etc to hide Slashdot Video box?  (Read 2696 times)

TaoPhoenix

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 4,548
    • View Profile
    • Donate to Member
IDEA: Greasemonkey script etc to hide Slashdot Video box?
« on: June 15, 2015, 06:30:09 PM »
Slashdot has been struggling for a while, and Dice seems to have its own ideas on UI layout. It seems the much reviled Beta one is parked for a while, but a few days ago, something truly awful appeared: This video box:

aaaa 1314213E45381CC6.pngIDEA: Greasemonkey script etc to hide Slashdot Video box?

It's pretty clear in the page source it gets pulled with (variants by day?) code that starts off with stuff like this:

aaaab.pngIDEA: Greasemonkey script etc to hide Slashdot Video box?

So I'm looking for some way it simply gets hidden local side, then the rest of the page would just be normal and I can pretend it wasn't there.

Mouser seems to think this is a good thing for Greasemonkey. (Which I've never used much! So I'll need some user help!)

Thoughts?

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,409
    • View Profile
    • Donate to Member
Re: IDEA: Greasemonkey script etc to hide Slashdot Video box?
« Reply #1 on: June 15, 2015, 08:19:45 PM »
Do you have a link to a page with it on?

I don't get it just looking around the site, (not even with uBlock/etc disabled), so maybe it's specific pages or a geo-localised object.

Edit: Just tried with a VPN and still don't see it, (using IE, Pale Moon, Dragon, or IceDragon).
« Last Edit: June 15, 2015, 08:40:46 PM by 4wd »

TaoPhoenix

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 4,548
    • View Profile
    • Donate to Member
Re: IDEA: Greasemonkey script etc to hide Slashdot Video box?
« Reply #2 on: June 15, 2015, 08:46:52 PM »
Do you have a link to a page with it on?

I don't get it just looking around the site, (not even with uBlock/etc disabled), so maybe it's specific pages or a geo-localised object.

Edit: Just tried with a VPN and still don't see it, (using IE, Pale Moon, Dragon, or IceDragon).

That's really weird!
Geo-Localized!? Where are you?
I get it on EVERY day's front page!
>:(

It's about 6 down on the page for me right now, and about there every time. Slashdot does a "rolling live update" with a script, and it always is forced to be about that spot on the page.


4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,409
    • View Profile
    • Donate to Member
Re: IDEA: Greasemonkey script etc to hide Slashdot Video box?
« Reply #3 on: June 15, 2015, 09:25:42 PM »
Do you have a link to a page with it on?

I don't get it just looking around the site, (not even with uBlock/etc disabled), so maybe it's specific pages or a geo-localised object.

Edit: Just tried with a VPN and still don't see it, (using IE, Pale Moon, Dragon, or IceDragon).

That's really weird!
Geo-Localized!? Where are you?

Australia

Quote
I get it on EVERY day's front page!

Found it!

Strange, I could have sworn it wasn't there the first time I looked.  Guess my brain's not completely caffeinated yet  :-[

Slashdot-VideoBytes.user.js
Code: Javascript [Select]
  1. // ==UserScript==
  2. // @name /. VideoBytes kill Kill KILL
  3. // @namespace I'm responsible
  4. // @include http://slashdot.org/*
  5. // ==/UserScript==
  6.  
  7. // Just removes the  element with id 'slideshow-wrap'
  8. function remove(id) {
  9.   return (elem=document.getElementById(id)).parentNode.removeChild(elem);
  10. }
  11.  
  12. remove('slideshow-wrap');

That gets rid of the video images but leaves the placeholder, now I can see some source I'll try and get rid of the rest.

TaoPhoenix

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 4,548
    • View Profile
    • Donate to Member
Re: IDEA: Greasemonkey script etc to hide Slashdot Video box?
« Reply #4 on: June 15, 2015, 09:37:47 PM »
Glad my guess was good!
I can fake pretending most of the other stuff Dice is doing doesn't matter, but that one is in a league of its own!

(They also had the bright idea to stick polls into the news section, but at least those start minimized and I can just decide to ignore minimized things. But the video one is brutal!)

Hehe Actually, are you ready to make *two* of them? Because if you can make it so easy even I can use it, I'm gonna post it ON slashdot in like 9 comment threads, and watch them then get grumpy and change it!

(But then the people that catch on can just change the script themselves/their tech buddy.)

 :Thmbsup:

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,409
    • View Profile
    • Donate to Member
Re: IDEA: Greasemonkey script etc to hide Slashdot Video box?
« Reply #5 on: June 15, 2015, 10:04:33 PM »
Try this:

Slashdot-VideoBytes.user.js
Code: Javascript [Select]
  1. // ==UserScript==
  2. // @name /. VideoBytes kill Kill KILL
  3. // @namespace Modify it yourself
  4. // @include http://slashdot.org/*
  5. // ==/UserScript==
  6.  
  7. document.getElementsByClassName('vid-river-header')[0].outerHTML = '';
  8. document.getElementsByClassName('units-12 river-group')[0].outerHTML = '';

Rather simplistic, if the class name changes each day then it will only work for the days that it matches.  Your best bet is to grab all matching tags and iterate through them to find something particular to those DOM elements, then remove them.
« Last Edit: June 16, 2015, 01:57:05 AM by 4wd, Reason: Did not need the var declarations ... stoopid :/ »

TaoPhoenix

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 4,548
    • View Profile
    • Donate to Member
Re: IDEA: Greasemonkey script etc to hide Slashdot Video box?
« Reply #6 on: June 16, 2015, 01:27:04 AM »
Recall, I was saying I never used scripts before, can you give me a primer on what to do with it?
Something bothers me, it looks too short ...

Also I don't exactly understand how it works, but a guess was a script could look for the starter and closer and nuke everything in between.


4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,409
    • View Profile
    • Donate to Member
Re: IDEA: Greasemonkey script etc to hide Slashdot Video box?
« Reply #7 on: June 16, 2015, 02:12:07 AM »
Create a file called Slashdot-VideoBytes.user.js and copy the code from the post above into it, then save it.

Drag'n'Drop it onto Pale Moon/Firefox, if GreaseMonkey is installed it will see it as a valid Userscript and ask if you want to install it.


What it does:

Code: HTML [Select]
  1. </article><article id="firehose-000" class="fhitem fhitem-poll article usermode thumbs grid_24">
  2.         <header>
  3.                 <div class="vid-river-header">
  4.                         <span>
  5.                                 <a href="/videos">Video Bytes</a>
  6.                         </span>
  7.                         <span class="sub-link pull-right">
  8.                                 <a href="/videos">view more</a>
  9.                         </span>
  10.                 </div>
  11.         </header>
  12.         <div class="units-12 river-group">
  13.            <div id="slideshow-wrap">
  14.               <input type="radio" id="button-6" name="controls" checked="checked"/>
  15.               <label for="button-6"></label>

The above is the section of the page source that deals with the VideoBytes display.

Code: Javascript [Select]
  1. document.getElementsByClassName('vid-river-header')[0].outerHTML = '';

To break this statement down simply, (I'm nothing if not simple):

Code: Text [Select]
  1. document.getElementsByClassName('vid-river-header')
Retrieves an array (it's not really an array but for this explanation it'll do) of DOM elements that have the class vid-river-header which you can see in line 3 of the page source above.

There's only one instance of this class in the whole page, it's the first in our array so we reference it as 0 (zero numbered):
Code: Text [Select]
  1. [0]

We reference the HTML that contains this class using .outerHTML, this will also include all its descendents, (the following <span> tags, etc), until the end of the tag.

Code: Text [Select]
  1. document.getElementsByClassName('vid-river-header')[0].outerHTML

references all of this:

Code: Text [Select]
  1. <div class="vid-river-header">
  2.   <span>
  3.     <a href="/videos">Video Bytes</a>
  4.   </span>
  5.   <span class="sub-link pull-right">
  6.     <a href="/videos">view more</a>
  7.   </span>
  8. </div>

Finally, we replace it with '' (a pair of apostrophes, ie. nothing).  So the page source for that class effectively becomes:
Code: Text [Select]
  1. <header>
  2.  
  3. </header>

The same thing happens with the next line except we're now looking for a class of units-12 river-group.

The first line takes care of the blue VideoBytes header, the second takes care of everything in the box below it.

As I said, it's a rather simplistic solution and a simple change of the class name will break it but it works with the source I can currently see.
« Last Edit: June 16, 2015, 07:26:36 AM by 4wd, Reason: Multi-GFU »

TaoPhoenix

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 4,548
    • View Profile
    • Donate to Member
Re: IDEA: Greasemonkey script etc to hide Slashdot Video box?
« Reply #8 on: June 16, 2015, 06:15:05 AM »

Whee!
See? 2 lines of code! Bye bye videos!

Smart people beat the common denominator every time! Go DC!
 :Thmbsup:

TaoPhoenix

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 4,548
    • View Profile
    • Donate to Member
Re: IDEA: Greasemonkey script etc to hide Slashdot Video box?
« Reply #9 on: June 16, 2015, 04:41:58 PM »
"We reference the HTML that contains this class using .outerHTML, this will also include all its descendents, (the following <span> tags, etc), until the end of the tag."

That's really the magic bullet, and I think it can be surprisingly adapted to ...
well ... nuke stuff.

I'm betting it will eat a lot of those sliders, and maybe lots of other ad scripts, complementing adblock.

Meanwhile slashdot isn't known for pushing fast code changes, so I bet the basic one will work for a good while, and I'll try to report back in with some good "nukes".

Stay tuned!

« Last Edit: June 16, 2015, 04:59:07 PM by TaoPhoenix »

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,409
    • View Profile
    • Donate to Member
Re: IDEA: Greasemonkey script etc to hide Slashdot Video box?
« Reply #10 on: June 16, 2015, 06:32:13 PM »
You should check out the other getElement(s) methods as they can get specific tags, ids, and everything other than just classes.

http://www.w3schools...dom_obj_document.asp

The above has examples you can edit that interact with you.

TaoPhoenix

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 4,548
    • View Profile
    • Donate to Member
Re: IDEA: Greasemonkey script etc to hide Slashdot Video box?
« Reply #11 on: June 16, 2015, 06:54:27 PM »

Sure, some day when I have a matching couple of pages to hack at!

I have glanced at web mag code, it's kinda clean as far as it goes. That's why I like your method (pun intended?) - because after a pseudo code like

header
news
video
comments

then it goes something like "begin red-mountain advert slider".

So you just nuke the whole thing and be done with it.