Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Firefox Greasemonkey - Invision Board Tool For Warning, IPB warning shortcut
BuffaloHELP
post Mar 11 2007, 04:29 AM
Post #1


Desperately seeking "any key" to continue...
Group Icon

Group: Admin
Posts: 3,438
Joined: 23-April 05
From: Trap17 storage box
Member No.: 6,042



Greasemonkey is popular for Firefox users in making any webpage to give that a little personal touch.

I found Greasemonkey extension for IPB for moderating WARN feature. You can have lists of commonly used warning messages and have it as pull-down menu style when issuing a warning. Very cool! The simple thing about this extension is how easy to modify to fit your needs.

This extension, called IPB Moderator Reasonator ( http://www.whiteacid.org/greasemonkey/#ipb...ator_reasonator ), shows only when you are at the warning page. Installation is very simple. After the installation open Manage User Scripts and edit the URL to your own IPB forum board (currently installed for Trap17 on my Firefox).

It is simply amazing.

The source code is listed here just in case the site does not show

CODE
// ==UserScript==
// @name           IPB moderator reasonator
// @namespace      http://mywebsite.com/myscripts
// @description    Provides a select box with common reasons to warn people on the IPB warning page
// @include       http://www.cirticalsecurity.net/index.php?act=warn&type=add&*
// ==/UserScript==

textarea = document.getElementsByName('reason')[0]
parent = textarea.parentNode
br = document.createElement('br')
//The drop down menu
select = document.createElement('select')
select.setAttribute('onchange','warn_add_reason(this.value)')
//Now lets create the "append rules link" button
button = document.createElement('input')
button.type = "button"
button.value = "append rules link"
button.setAttribute('onclick','warn_add_rules()')

//Add the reasons
reasons = new Array()
reasons[0] = new Array("Select a reason","Select a reason") //Do not change
reasons[1] = new Array("Multiple consecutive posts","You have created several consecutive posts in one thread. This is usually regarded as spam.")
reasons[2] = new Array("Linking to a site/program with relation to hacking it","You have linked to a site with relation to hacking it, this is against our rules. I have removed your thread.")
reasons[3] = new Array("Spamming","You have have spammed, the offending post has been removed")
reasons[4] = new Array("Necroposting","You have posted a non-constructive post in a long dead topic.")
reasons[5] = new Array("Abuse","You have been abusing other members on the forum.")
reasons[6] = new Array("Posting spoilers","You have posted blatant spoilers.")
reasons[7] = new Array("Asking for warez","You have asked where you can get illegal programs/music/films.")
reasons[8] = new Array("Giving link to warez","You have given links to illegal programs/music/films.")
reasons[9] = new Array("Signature too large","Your signature is too large.")
reasons[10] = new Array("Avatar too large","Your avatar is too large.")

for (i=0; i<reasons.length; i++)
{
    eval("child_"+i+" = document.createElement('option')")
    reason = escape(reasons[i][1]) //so quotes can be used
    eval("child_"+i+".value = '"+reason+"'")
    eval("child_"+i+".innerHTML = '"+reasons[i][0]+"'")
    eval("select.appendChild(child_"+i+")")
}

parent.insertBefore(select,textarea)
parent.insertBefore(button,textarea)
parent.insertBefore(br,textarea)

// executed from within the page
function warn_add_reason(reason)
{
    document.getElementsByName('reason')[0].value = unescape(reason)
}
function warn_add_rules()
{
    domain        = location.href.substr(0,location.href.substring(8,location.href.length).indexOf("/")+8) //get the domain name
    document.getElementsByName('reason')[0].value += "\n[url=\""+domain+"/?act=boardrules\"]Read the rules[/url]"
}
unsafeWindow.eval(warn_add_reason.toString())
unsafeWindow.eval(warn_add_rules.toString())
Go to the top of the page
 
+Quote Post
jlhaslip
post Mar 11 2007, 06:43 AM
Post #2


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,882
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



As you find and install Greasemonkey, there are a couple of thinghs to edit in the script. The changes can be performed after the install by selecting the Greasemonkey extension in the Tools Menu.

To Change the url and text string for the "Rules Link",
Find :
CODE
document.getElementsByName('reason')[0].value += "\n[url=\""+domain+"/?act=boardrules\"]Read the rules[/url]"
}

Change to :
CODE
document.getElementsByName('reason')[0].value += "\n[url=\""+domain+"/?act=Help&CODE=01&HID=18\"]Trap17 Readme [/url]"
}


To Change the Host and page which triggers the Dropdown menu,
Find :
CODE
// @include       http://www.cirticalsecurity.net/index.php?act=warn&type=add&*

Change to :
CODE
// @include       http://www.trap17.com/forums/index.php?act=warn&type=add&*



Also, the Drop-down can be made tpo appear when you are reducing a warning by including the following Wildcard string in the list of pages:

CODE
http://www.trap17.com/forums/index.php?act=warn&type=minus&*


It might be suitable to add the reasons for reducing the warnings if you are going to do this.
Choose to edit the script in the Tools > Greasemonkey > Manage Script > Edit. (specify your Editor of choice)
Go to the top of the page
 
+Quote Post
electriic ink
post Mar 11 2007, 05:40 PM
Post #3


Incest is a game the whole family can play.
Group Icon

Group: [MODERATOR]
Posts: 1,205
Joined: 11-February 05
From: Heaven
Member No.: 3,709



That's great! It will certainly save a fair amount of time. I've changed the reasons so that they are more suited to Trap17 but moderators of other IPB forums could easily use this as well:

CODE
reasons[0] = new Array("Select a reason","Select a reason for adding to the warning") //Do not change
reasons[1] = new Array("===================================", "Select a reason for adding to the warning")
reasons[2] = new Array("Abusing Members","Abuse of other members on the forum:")
reasons[3] = new Array("Advertising", "Advertising:")
reasons[4] = new Array("CODE tags for code missing","Posting code without CODE tags:")
reasons[5] = new Array("Double Posting","Double posting:")
reasons[6] = new Array("Illegible Text Style (Repeated Offence)", "Illegible Text Style:")
reasons[7] = new Array("Lack of Contribution","Posting lacking contribution:")
reasons[8] = new Array("Personal Information Posted","Posting private information:")
reasons[9] = new Array("Plagiarising","Direct copy and pasting without use of QUOTE tags:")
reasons[10] = new Array("Pornography", "Pornographical material:")
reasons[11] = new Array("Posting a link to an illegal website","Posting a link to an illegal website:")
reasons[12] = new Array("Referral links","Posting referral links:")
reasons[13] = new Array("Signature Too Big (Repeated Offence)","Signature still too large.")
reasons[14] = new Array("Triple Posting", "Triple posting:")
reasons[15] = new Array("Warez Discussion","Engaging in the discussion of warez:")
reasons[16] = new Array("===================================", "Select a reason for adding to the warning")
reasons[17] = new Array("Other Offence", "")


If you wanted to use the script so it dealt with lowering the warning then you'd need to use this code:

Immediately after reasons = new Array(), add:
CODE
if (location.href.substr(53,3) == "add") {


This works for trap17.com but not necessarily for other domains. For other domains, the number you would need to change is 53. How do you find what number to change it to? You take a normal link to warn a member:

http://www.trap17.com/forums/index.php?act=warn&type=add&mid=3709&t=1&st=0

Count how many characters there are up to the blue letter and that's your number! A painstakingly long process but I can't think of another way to do it (my JS knowledge is very limited). Anyway:

Then you insert all your reasons to raise the warn level of the member. Eg:

CODE
reasons[0] = new Array("Select a reason","Select a reason for adding to the warning") //Do not change
reasons[1] = new Array("===================================", "Select a reason for adding to the warning")
reasons[2] = new Array("Abusing Members","Abuse of other members on the forum:")
reasons[3] = new Array("Advertising", "Advertising:")
reasons[4] = new Array("CODE tags for code missing","Posting code without CODE tags:")
reasons[5] = new Array("Double Posting","Double posting:")
reasons[6] = new Array("Illegible Text Style (Repeated Offence)", "Illegible Text Style:")
reasons[7] = new Array("Lack of Contribution","Posting lacking contribution:")
reasons[8] = new Array("Personal Information Posted","Posting private information:")
reasons[9] = new Array("Plagiarising","Direct copy and pasting without use of QUOTE tags:")
reasons[10] = new Array("Pornography", "Pornographical material:")
reasons[11] = new Array("Posting a link to an illegal website","Posting a link to an illegal website:")
reasons[12] = new Array("Referral links","Posting referral links:")
reasons[13] = new Array("Signature Too Big (Repeated Offence)","Signature still too large.")
reasons[14] = new Array("Triple Posting", "Triple posting:")
reasons[15] = new Array("Warez Discussion","Engaging in the discussion of warez:")
reasons[16] = new Array("===================================", "Select a reason for adding to the warning")
reasons[17] = new Array("Other Offence", "")


Put this code in:
CODE
} else {


Then, put all you reasons for lowering a member's warning. Eg:

CODE
reasons[0] = new Array("Select a reason","Select a reason for lowering the warning") //Do not change
reasons[1] = new Array("===================================", "Select a reason for lowering the warning")
reasons[2] = new Array("Good posts", "Good posts recently")
reasons[3] = new Array("Helpful member", "Thanks for being a helpful member")
reasons[4] = new Array("Reporting posts", "Thanks for reporting some posts recently")
reasons[5] = new Array("Superb post", "Fantastic post:")
reasons[6] = new Array("===================================", "Select a reason for lowering the warning")
reasons[7] = new Array("Other Reason", "")


Put this code in:
CODE
}


Then it should act as two scripts that perform similar functions. It displays reasons to add to or lower warnings on their relevant pages. The next step, of course, would be to make it so that auto-writes the PM.

Thanks BuffaloHELP!
Go to the top of the page
 
+Quote Post
jlhaslip
post Mar 11 2007, 07:15 PM
Post #4


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,882
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



The easiest way to mod this thing might be by using the edit capabilities within the Greasemonkey itself.
Just install the script as per the author's page, then select to edit the script from Tools > Greasemonkey > Manage Users Sripts > Edit.
Cut and paste the following re-structured page into the editor, overwriting the original, to make the script suitable for Trap17 Mods.

CODE

// ==UserScript==
// @name IPB moderator reasonator - Trap17 version
// @namespace http://www.trap17.com/forums/index.php?sho...t=0#entry313464
// @description Provides a select box with common reasons to warn people on the IPB warning page
// @include http://www.trap17.com/forums/index.php?act=warn&*
// ==/UserScript==

textarea = document.getElementsByName('reason')[0]
parent = textarea.parentNode
br = document.createElement('br')
//The drop down menu
select = document.createElement('select')
select.setAttribute('onchange','warn_add_reason(this.value)')
//Now lets create the "append rules link" button
button = document.createElement('input')
button.type = "button"
button.value = "append rules link"
button.setAttribute('onclick','warn_add_rules()')

//Add the reasons
reasons = new Array()
if (location.href.substr(53,3) == "add") {
reasons[0] = new Array("Select a reason","Select a reason for adding to the warning") //Do not change
reasons[1] = new Array("===================================", "Select a reason for adding to the warning")
reasons[2] = new Array("Abusing Members","Abuse of other members on the forum:")
reasons[3] = new Array("Advertising", "Advertising:")
reasons[4] = new Array("CODE tags for code missing","Posting code without CODE tags:")
reasons[5] = new Array("Double Posting","Double posting:")
reasons[6] = new Array("Illegible Text Style (Repeated Offence)", "Illegible Text Style:")
reasons[7] = new Array("Lack of Contribution","Posting lacking contribution:")
reasons[8] = new Array("Personal Information Posted","Posting private information:")
reasons[9] = new Array("Plagiarising","Direct copy and pasting without use of QUOTE tags:")
reasons[10] = new Array("Pornography", "Pornographical material:")
reasons[11] = new Array("Posting a link to an illegal website","Posting a link to an illegal website:")
reasons[12] = new Array("Referral links","Posting referral links:")
reasons[13] = new Array("Signature Too Big (Repeated Offence)","Signature still too large.")
reasons[14] = new Array("Triple Posting", "Triple posting:")
reasons[15] = new Array("Warez Discussion","Engaging in the discussion of warez:")
reasons[16] = new Array("===================================", "Select a reason for adding to the warning")
reasons[17] = new Array("Other Offence", "")
} else {
reasons[0] = new Array("Select a reason","Select a reason for lowering the warning") //Do not change
reasons[1] = new Array("===================================", "Select a reason for lowering the warning")
reasons[2] = new Array("Good posts", "Good posts recently")
reasons[3] = new Array("Helpful member", "Thanks for being a helpful member")
reasons[4] = new Array("Reporting posts", "Thanks for reporting some posts recently")
reasons[5] = new Array("Superb post", "Fantastic post:")
reasons[6] = new Array("===================================", "Select a reason for lowering the warning")
reasons[7] = new Array("Other Reason", "")
}
for (i=0; i<reasons.length; i++)
{
eval("child_"+i+" = document.createElement('option')")
reason = escape(reasons[i][1]) //so quotes can be used
eval("child_"+i+".value = '"+reason+"'")
eval("child_"+i+".innerHTML = '"+reasons[i][0]+"'")
eval("select.appendChild(child_"+i+")")
}

parent.insertBefore(select,textarea)
parent.insertBefore(button,textarea)
parent.insertBefore(br,textarea)

// executed from within the page
function warn_add_reason(reason)
{
document.getElementsByName('reason')[0].value = unescape(reason)
}
function warn_add_rules()
{
domain = location.href.substr(0,location.href.substring(8,location.href.length).indexOf("/")+8) //get the domain name
document.getElementsByName('reason')[0].value += "\nTrap17 Readme "
}
unsafeWindow.eval(warn_add_reason.toString())
unsafeWindow.eval(warn_add_rules.toString())


Notice from BuffaloHELP:
Note that "trap17 readme" link has been parsed within the CODEBOX. Please remove "http://" after [url= and you'll be fine. See the original code posted for clarification
Go to the top of the page
 
+Quote Post
BuffaloHELP
post Mar 11 2007, 08:59 PM
Post #5


Desperately seeking "any key" to continue...
Group Icon

Group: Admin
Posts: 3,438
Joined: 23-April 05
From: Trap17 storage box
Member No.: 6,042



The disadvantage of reverse engineering is that this code needs to be first understood before it can be customized. And I, not knowing any javascript, took a bit longer to figure out what makes this thing tick.

By editing following lines with my modification, you can have the same pull-down option to appear whenever you are FAST REPLY or REPLY mode.

Edit to:

1) First line
CODE
textarea = document.getElementsByName('Post')[0]


2) Find function warn_add_reason(reason)
CODE
document.getElementsByName('Post')[0].value = unescape(reason)


3) Find function warn_add_rules()
CODE
document.getElementsByName('Post')[0].value += "\n[url=\""+domain+"/?act=boardrules\"]Read the rules[/url]"


All I did was replace 'reason' textarea name to 'Post' name tag.

I initially used @include as a wild card to test it out without prejudice. But the better @include would be
CODE
@include    http://www.trap17.com/forums/*

Since IP.Board sets <textarea name="Post"... having a wider include will work to an advantage.

I also believe that having different scripts with prescripted reasons are better than having one script with all possible reasons.

One behavior I noticed is that the pull-down menu will override anything in the <textarea>. "append rules link" will append but as soon as you select another pull-down option, it will be cleared and inserted with the new selection. This is something to be considered when trying to use this while edting a post (it will clear the original post and replace it with your message). The javascript "append rules link" method should be used in this case.

The next agenda would be to modify the script and insertion to automatically fill in PM subject and PM message with the same pull-down option during the warn issuing stage. **DONE**

Find function warn_add_reason(reason) and change to
CODE
function warn_add_reason(reason)
{
    document.getElementsByName('reason')[0].value = unescape(reason)
    // add to PM box according to reasons
    document.getElementsByName('subject')[0].value = "Warning level adjusted"
    document.getElementsByName('contact')[0].value = unescape(reason)
}


Find function warn_add_rules() and change to
CODE
function warn_add_rules()
{
    domain        = location.href.substr(0,location.href.substring(8,location.href.length).indexOf("/")+8) //get the domain name
    document.getElementsByName('reason')[0].value += "\n[url=\""+domain+"/?act=boardrules\"]Read the rules[/url]"
    // add to PM box when clicked
    document.getElementsByName('contact')[0].value += "\n[url=\""+domain+"/?act=boardrules\"]Read the rules[/url]"
}


These changes will allow warning reason, PM subject and PM message areas to be filled in simultaneously smile.gif All done and have fun!

Next agenda is to see if it's possible if this plug can only be used by approved moderators (or any other Greasemonkey user scripts--since anyone with Firefox can use this mod, especially if we develop one for post edit message plug-ins)

This post has been edited by BuffaloHELP: Mar 12 2007, 02:44 AM
Go to the top of the page
 
+Quote Post
Imtay22
post Mar 12 2007, 09:24 PM
Post #6


Super Member
*********

Group: Members
Posts: 292
Joined: 27-January 07
From: Winter is cold here.
Member No.: 37,984
Spam Patrol



Well I will try to use this for my board. Thanks for the find BuffaloHELP! But first i have to buy an invision licence though...
Go to the top of the page
 
+Quote Post
Saint_Michael
post Mar 13 2007, 02:05 AM
Post #7


$p4m 0n j00 $h4m3 m3 0nc3 $p4m 0n m3 $h4m3 m3 7\/\/1c3
*********************

Group: [HOS