I'm trying to modify http://play.google.com/music/ with a userscript through Tampermonkey on Chrome, and I've hit a wall trying to target a specific div on the page - something seems to be preventing me from modify it.
You'll need to log into a google account (and maybe add a song if you don't have any) to see, but it would appear that the element
<div class="new-listen-now g-content three-column" style="opacity: 1;">
and all it's children are totally unable to be targeted by my script. Here's what the script looks like:
// ==UserScript==
// @name Google Play Music Tweaks
// @description:en My personal tweaks for Google Play Music
// @namespace www.reaverxai.com
// @require http://code.jquery.com/jquery-1.11.3.min.js
// @include http://play.google.com/music/listen*
// @include https://play.google.com/music/listen*
// @include http://music.google.com/music/listen*
// @include https://music.google.com/music/listen*
// @match http://play.google.com/music/listen*
// @match https://play.google.com/music/listen*
// @match http://music.google.com/music/listen*
// @match https://music.google.com/music/listen*
// @run-at document-end
// ==/UserScript==
$('.nav-toolbar').attr( "class", "testclass");
$('.recommended-header').attr( "class", "testclass");
The first line of jQuery works fine, as you'd expect it to, but the second, which targets a child element of the one mentioned above, doesn't do anything.
.addClass('myClass');
Is'.recommended-header'
correct ? Is it present in the DOM ? – Lauromine Sep 10 '15 at 12:57attr( 'class', 'myClass')
!=.addClass('myClass');
– Hacketo Sep 10 '15 at 12:59attr
will set the attribute,addClass
add a class to the list, but maybe OP do not know that and wantaddClass
– Hacketo Sep 10 '15 at 13:00