IMDB: Reference view (old style) improvement

in Ideas and script requests
Subscribe to IMDB: Reference view (old style) improvement 10 posts, 3 voices



El Duderino User
OperaWindows

I prefer the reference view, but new style has some nice ideas, like:

- placing important info after (or below)the movie title, so no need for scrolling.

Here's the pic: http://simplest-image-hosting.net/jpg-0-3300

So basically, I just want to move something from one place to another. Is this hard to do?

 
mike cupcake Scriptwright
FirefoxWindows

IMDB looks completely different for me + it has all that info at the top of the page.

are you already using a script to get that look? which one?

 
El Duderino User
OperaWindows

No, you need to register on imdb to get that layout, then go to https://secure.imdb.com/register-imdb/siteprefs and check "Show previous title and name page design (reference view)".

The green color is just the css I use.

 
mike cupcake Scriptwright
FirefoxMacintosh

It's a little fiddly to reference the bits of data as they don't have unique ID tags, but this approach works in Firefox+GM:

// get array of all the 'info-content' divs within the 'tn15content' div
pageContent = document.getElementById('tn15content').getElementsByClassName('info-content');

// select the one that contains the release date
releaseDate = pageContent[5];

// clone the div
releaseDate2 = releaseDate.cloneNode(true);

// insert clone after the title div 
title = document.getElementById('tn15title');
title.parentNode.insertBefore(releaseDate2, title.nextSibling);

 
El Duderino User
OperaWindows

Thanks Mike, but unfortunately it works random, probably because of
releaseDate = pageContent[5]; (Release Date is not always the fifth)

I've found a script which maybe holds the key. It finds stuff by name and removes them.
http://userscripts.org/scripts/review/83580

For example:

// MOVIEmeter, Contact, NewsDesk
rm('id("tn15content")/div[starts-with(h5, "MOVIEmeter") or starts-with(h5, "Contact") or starts-with(h5, "NewsDesk")]');

I've tried replacing "pageContent[5];" in your script with:

releaseDate = ('id("tn15content")/div[starts-with(h5, "Release Date")]');

but it didn't work.

 
mike cupcake Scriptwright
FirefoxMacintosh

Ah silly me for not checking IMDB used a fixed order, yep we'll need to be more clever than saying 'choose the fifth one'

What you've tried there won't work because the string is designed for use in an Xpath search. See how it's passed onto the rm and xp functions in the script you've taken it from.

Xpath would be one way to do it but is kinda overkill for referencing single elements, looping through the data DIVs until we see 'Release Date' would accomplish this fine + is more interesting to code :-) I'll have another look in a bit.

 
AmpliDude Scriptwright
FirefoxWindows

If you don't have anything against using unsafeWindow, then you can use jQuery from imdb.com website:

(function() {

if (top != self) return; // to avoid running script in frames

$ = unsafeWindow.$; // jQuery on imdb.com website
console.log($("*.info:contains('Release Date') > div"));

})();

 
mike cupcake Scriptwright
FirefoxMacintosh

Give this a try:

var insertTarget = document.getElementById('tn15title');
var dataHeadings = document.getElementById('tn15content').getElementsByTagName('h5');

for ( i=0; i < dataHeadings.length; i++ ) {
  text = dataHeadings[i].textContent;
  if (text.indexOf("Release Date:") != -1 || text.indexOf("Runtime:") != -1) {
    cloneItem(dataHeadings[i].parentNode);  // clone the parent node of the heading
  }
}

function cloneItem(item) {
   // clone the div
  item2 = item.cloneNode(true);

  // insert clone
  insertTarget.parentNode.insertBefore(item2, insertTarget.nextSibling);
}

 
El Duderino User
OperaWindows

Thank you Mike it works and looks great, plus I've learned something.

 
mike cupcake Scriptwright
FirefoxWindows

You're welcome, I'm still trying to remember the exact command names for all this stuff instead of looking them up each time - every bit of scripting helps!