Blizzhackers

Return of the Jedi

* Login   * Register    * FAQ    * Search

Join us on IRC: #bh@irc.synirc.net (or Mibbit Web IRC)


MuleFactory


It is currently Wed May 22, 2013 6:27 am


All times are UTC [ DST ]





Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: [Greasemonkey] phpbb3 ignore
PostPosted: Sat Mar 12, 2011 9:35 pm 
 
User Gold
User Gold
User avatar

Joined: Mon Jan 05, 2004 10:59 pm
Location: ͫ̉ͦ̊̀̔ͧͮ͆̽ͦͩ͋̌͗̚̚҉̵͖̟͙̮͈̼̹̞͝ͅ,UK
Okay, so most of this just includes jQuery.

I read about GM_setValue and getValue, but I don't know how to call them from the page, or if I should allow it via unsafeWindow.

I would quite like to add a "show" and a "hide" button, but I don't know how to do that without using unsafeWindow to call setValue to save the list of users.

It'd just make it more convenient.

Cheers :)

// ==UserScript==
// @name           phpbb3_user_ignore
// @namespace      none.exists.here
// @description    Ignore users on phpbb3
// @include        *.blizzhackers.cc/viewtopic.php?*
// @include        blizzhackers.cc/viewtopic.php?*
// ==/UserScript==

var $;

// Add jQuery from http://joanpiedra.com/jquery/greasemonkey/
(function(){
   if (typeof unsafeWindow.jQuery == 'undefined') {
      var GM_Head = document.getElementsByTagName('head')[0] || document.documentElement,
         GM_JQ = document.createElement('script');

      GM_JQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';
      GM_JQ.type = 'text/javascript';
      GM_JQ.async = true;

      GM_Head.insertBefore(GM_JQ, GM_Head.firstChild);
   }
   GM_wait();
})();

// Check if jQuery's loaded
function GM_wait() {
   if (typeof unsafeWindow.jQuery == 'undefined') {
      window.setTimeout(GM_wait, 100);
   } else {
      $ = unsafeWindow.jQuery.noConflict(true);
      letsJQuery();
   }
}


// All your GM code must be inside this function
function letsJQuery() {
   var temp;
   var user_count = GM_getValue('user_count');
   var users = new Array(
      'user1',
      'user2'
   );
   
   $('.postauthor').each( function() {
      t = $(this).html();
      index = $.inArray(t, users); // Returns index, or -1
      if( index > -1 )
      {
         $(this).parent().parent().next().css({'display' : 'none', 'height' : '0'});
         // hide and show "show"
      } else {
         // show "hide" button
      }
   });
}

_________________
There is no opinion, however absurd, which men will not readily embrace as soon as they can be brought to the conviction that it is generally adopted. Example affects their thought, just as it affects their action. They are like sheep following the bell-wether wherever he leads them. They would sooner die than think.

Top
 Profile  
 Post subject: Re: [Greasemonkey] phpbb3 ignore
PostPosted: Tue Mar 29, 2011 6:48 am 
 
Section Leader
Section Leader

Joined: Fri Jul 05, 2002 8:51 pm
Location: /sbin/
You can use jQuery via @require in newer versions of greasemonkey, and you should most definitely not allow access to any GM_* functions from unsafeWindow.

_________________
D2BS
Programming motherfuckers... DO YOU SPEAK IT?!
I, for one, welcome our new black overlo... I mean, president!
  1. Create signature generator.
  2. ???
  3. Profit!

Top
 Profile  
 Post subject: Re: [Greasemonkey] phpbb3 ignore
PostPosted: Thu Mar 31, 2011 8:43 pm 
 
User Gold
User Gold
User avatar

Joined: Mon Jan 05, 2004 10:59 pm
Location: ͫ̉ͦ̊̀̔ͧͮ͆̽ͦͩ͋̌͗̚̚҉̵͖̟͙̮͈̼̹̞͝ͅ,UK
You can use jQuery via @require in newer versions of greasemonkey, and you should most definitely not allow access to any GM_* functions from unsafeWindow.


Thanks. I've never made a greasemonkey script before.

_________________
There is no opinion, however absurd, which men will not readily embrace as soon as they can be brought to the conviction that it is generally adopted. Example affects their thought, just as it affects their action. They are like sheep following the bell-wether wherever he leads them. They would sooner die than think.

Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron