Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

  (email not shown publicly)
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Saturday August 23, 2008
04:25 AM

GreaseMonkey: Ignoring users on use.perl

[ #37259 ]

Just playing around. It's not overly useful, but it's nice to see it work (and it's fragile). Replace 'some_user_name' below to ignore the user of your choice. No, it doesn't have a lot of features, but it was fun to write :)

// ==UserScript==
// @name           ignore.use.perl
// @namespace
// @description    Hide Annoying Users
// @include*
// ==/UserScript==

(function() {
    var user = 'some_user_name';
    var href = '//'+user+'/';

    // I want zero-width positive look ahead assertions in XPath.  That
    // would eliminate the awful parentNode.parentNode.parentNode;
    // Does this feature exist and I just don't know it?

    var divs = document.evaluate(

    for ( var i=0; i < divs.snapshotLength; i++ ) {
        var node       = divs.snapshotItem(i).parentNode.parentNode.parentNode;
        node.innerHTML = '<p><strong>Ignoring '+user+' via GreaseMonkey</strong></p>';

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • It's possible, but I'm not sure how to handle multiple predicates. For the simple case, it looks like this:


    which pulls out all the divs which have a grandchild which is a span with a class of 'storyicons'.

    • You can put multiple predicates on a single path step. Something like /foo[@bar='baz'][@quux='qux'] is completely valid (and logically equivalent to /foo[@bar='baz' and @quux='qux']).

      • ah!

        So in the example above, it would be something like


        (I think)

        • Yes; or alternatively:

          "//div[@class='full' and .//div/div[@class='details']/a[@href='"+href+"']]"

        • Err, wait, no. Where did that .// in your second predicate come from? It would be either



          "//div[@class='full' and div/div[@class='details']/a[@href='"+href+"']]"

          You want those nested DIVs and As as direct child nodes of each other and of the node in question – you’re not looking for that subtree anywhere further down.