Code
// ==UserScript==
// @name Fix NekoSama's posts
// @namespace http://your.homepage/
// @version 0.1
// @description Changes NekoSama's font to normal black instead of giant green
// @author carteblanche
// @match http://forums.d2jsp.org/topic.php*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
$(document).ready(function() {
// fix all of nekosama's posts no matter what font/colour he uses
var a = $('a').filter(function(){
// find nekosama by his id; dont want him circumventing by changing his name
return $(this).attr('href') == 'user.php?i=434436';
});
if (a.length > 0){
// found him. now grab the element's grandparent
var dt = a.parent();
var dl = dt.parent();
// now find all <span> children
var spans = dl.find('span');
if (spans.length > 0){
spans.css('color', 'rgb(0,0,0)');
spans.css('font-size', '8pt');
}
}
});
that was pretty easy, using .parent() and .find(..)
Quote (Eep @ Nov 27 2014 03:16am)
there is a parent -> child selector, wonder if something like
Code
var elementsWithLinks = $('dt > a[href="some-link.com"]')
would work
though, when you say fix all the <span>, I am a little confused...it seems that posts are done in divs afaik
looks like the > only grabs the direct child, whereas find() will go through all descendants.
they are in divs i think, but <span> is used to change font styling. the dev tools in chrome are super helpful
This post was edited by carteblanche on Nov 27 2014 02:25am