Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Magicmat
Aug 14, 2000

I've got the worst fucking attorneys
Let me preface this by saying I am not a Javascript programmer in any way. It's been almost a decade since I touched it seriously, and in that time the language (and paradigm) have changed enough to make whatever I did remember almost useless.

With that said, I'm wondering if one of you guys can help me with a Greasemonkey script. The short version is that I'm trying to find a way to delete certain elements on the Facebook homepage (specifically, I want to get rid of "Highlights" items from people whom I don't care about.)

The proof-of-concept works fine either using getElementsByClassName() or jQuery. The problem comes in the fact that Facebook uses some AJAX'ified way to load pages. When you click a link it doesn't send you to a new page, it (so far as I can tell) uses some Javascript to fetch and the new page's data, erases the current page data and replaces it with the new data. Effectively, it's loading new pages without ever having to actually load a new page.

This is a problem because Greasemonkey scripts run when a page is loaded. If it never detects the page is reloaded, the script never runs. The effect is that my script works great when you first go to facebook.com, since that's a normal load, but if you click a link and then click a link back to the homepage, my script is completely oblivious because FB is 'cheating' on the load, and my script is never run, and the homepage is rendered unmolested.

Do any Facebook users now what/how I can hook whatever function it uses to load new pages to then trigger my script?

One lead I'm investigating is that FB seems to load some new iFrames on each cheater load, and those do trigger my script (though it then senses that the page being loaded, being simply a hidden data frame, isn't the homepage and then gives up.) Is there an easy way to maybe make my script, triggered inside an iFrame, 'break out' of the iFrame and then run on the containing page?

Adbot
ADBOT LOVES YOU

Magicmat
Aug 14, 2000

I've got the worst fucking attorneys

ronin109 posted:

Since you are creating a GM script (hence, developing this for Firefox only) you can use the DOMSubtreeModified or DOMNodeInserted events to signal the deletion script.
I was looking into that. Is the best method just to then trigger my item deletion function when the DOMNodeInserted event is fired? I'm afraid that may bog down the browser. Will there be any problem of an infinite loop if I'm just deleting items out of the DOM?

Magicmat
Aug 14, 2000

I've got the worst fucking attorneys
I'm looking for a JS library that lets me visualize network/force/etc. diagrams, but lets me use HTML objects (e.g., a div) as nodes.

I've seen a few different graphing libraries that do network/force/etc. diagrams, but they render their nodes in their native type, like SVG or <canvas> graphics. I need to use intractable <div>s as the node.

Magicmat
Aug 14, 2000

I've got the worst fucking attorneys

trinary posted:

I haven't used it myself, but the approach taken by d3.js might be the thing you're looking for.

http://mbostock.github.com/d3/ex/force.html
But isn't that just a SVG graphic? How would I attach a DIV to those nodes?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply