Reputation: 23
Since IMDB search can't exclude specific genres, I would like to hide the ones who I am not interested in, using Tampermonkey or Greasemonkey.
Every movie is inside a class named "lister-item mode-advanced"
:
Inside that is:
<span class="genre">
Animation, Adventure, Family </span>
Looking at other answers, I thought something like this could work:
// ==UserScript==
// @name NoAnimation
// @namespace NoAnimation
// @version 0.1
// @description try to take over the world!
// @author You
// @include *.imdb.com/search*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
// @grant GM_log
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_addStyle
// @grant GM_openInTab
// @grant GM_xmlhttpRequest
// @grant GM_registerMenuCommand
// ==/UserScript==
$("lister-item mode-advanced") .show ()
.has ("span.genre:contains('Animation')")
.hide ();
which doesn't work of course :(
I'm doing this test on akas.imdb.com/search/title?....
I hope I was clear enough. Can anyone give me advice? :)
Upvotes: 2
Views: 183
Reputation: 93613
The main mistake is, that is not how to specify class in a jQuery selector. It should have been $(".lister-item.mode-advanced")
.
But there are other problems:
mode-advanced
is not always present. May not always be a span, etc..show()
, for example).Here's a complete script that addresses these issues:
// ==UserScript==
// @name Hide Animations from IMBD search results
// @match *://*.imdb.com/search*
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// @grant GM_addStyle
// ==/UserScript==
//- The @grant directive is needed to restore the proper sandbox.
$(".lister-item").has (".genre:contains('Animation')").hide ();
Upvotes: 1