Page 1 of 1

greasemonkey script issue

Posted: Sat Oct 09, 2010 9:11 pm
by Loud-Noise
Loudnoise from mozillazine here. Over the last couple of versions I have been having trouble with a greasemonkey script. When I "allow all scripts" it works, when I don't it breaks until I give it permission to run. Even then it does not work correctly.

When I try to move spam I get the NoScript placeholder. Hovering over it it says:

<IFRAME>, unknown@http://forums.mozillazine.org/(long string giving the mcp.php info)&quickmod=1&
redirect=%2Fviewtopic.php (long string to the topic)

I have MozillaZine.org whitelisted.

Additional restrictions for untrusted sites has <iframe> is checked. Apply these restrictions to whitelisted sites too is unchecked.

Any more info needed?

Re: greasemonkey script issue

Posted: Sat Oct 09, 2010 9:26 pm
by loud-noise
Oh, there isn't anything related to the issue in the error console.

Re: greasemonkey script issue

Posted: Sun Oct 10, 2010 7:41 am
by Giorgio Maone
Loud-Noise wrote:Any more info needed?
  1. What does your noscript.forbidIFramesContext about:config preference look like?
  2. Even though I can see you're using Fx 3.6.10 here, are you trying to use this script on Firefox 4 (which still has a known bug messing with origins?)
  3. Most important, can I see the actual script and possibly try to reproduce?
At any rate, you should be able to work-around by selecting "Temporarily allow *@forums.mozillazine.org" from your NoScript Blocked Objects submenu.

Re: greasemonkey script issue

Posted: Sun Oct 10, 2010 5:33 pm
by loud-noise
noscript.forbidIFramesContext;3

3.6.10

Most likely. However I didn't write it so I need to get the ok from the author.

Re: greasemonkey script issue

Posted: Sun Oct 10, 2010 6:43 pm
by loud-noise
The script:

Code: Select all

////////////////////////////////////////////////
//Mozillazine Mod Controls                    //
//Verison 0.7.1                               //
//03/10/2009                                  //
//Author: Vectorspace                         //
////////////////////////////////////////////////

// ==UserScript==
// @name            Mozillazine Thread Quick Move Reply
// @namespace       http://homepage.ntlworld.com/vectorspace/greasemonkey/
// @author          Vectorspace
// @include         http://forums.mozillazine.org/viewtopic.php*
// @include         http://forums.mozillazine.org/posting.php*
// @description     Adds moderator controls to forum threads enabling one-click move and one-click move & reply
//                  Adds [Editlock] link to 1st post allowing reply as spam, santisie 1st post, and move to locked with one click
//                  Adds [Sanitise] link to all posts allowing sanitisation of post with one click
// ==/UserScript==


(function()
{
//------------------------------------------------------------------------------------------
//Thread Mode (Move/Move & Reply controls, Editlock Controls, sanitise controls)
    if (location.pathname.indexOf("viewtopic.php") > 0)
    {
        var msgBox=document.getElementById("message")
        var jumpTo=document.getElementById("f")
        var qMod=document.getElementById("quick-mod-select")
        var qReply=document.getElementById("options-quickreply")
        var qReplyDiv=document.getElementById("quick_reply")
        var postform=document.getElementById("postform")
        var redir=document.location.protocol+"//"+document.location.hostname+"/viewforum.php?f="+postform.elements.namedItem("f").value
        var replyFrameForm
        var moveSel
        var shadow
        var moveButton
        var replyButton
        var moveFrame
        var moveFrameFinal=false
        var replyFrameFinal=false
        var replyFrame
        var moveFrameListener
        var replyFrameListener
        var moveButtonListener=false
        var replyButtonListener=false
        var editLockLink
        var editURL
        var moveState=1     //1 = waiting. 2 = initial setup. On first load event, state = 3 (confirm screen). On second load event, state=4 (result screen). On analysis of result screen, state=5 (success) or state=0 (fail)
        var replyState=1
        var action
        var loadCount=0

        var sanitise="1"
        var autoSubmit="1"
        
        var creationTime=document.getElementsByName("creation_time")[0].value
        var formToken=document.getElementsByName("form_token")[0].value

        threadMode()
    }

//------------------------------------------------------------------------------------------
//Edit Post mode (sanitise/auto sanitise)
    if ((location.pathname.indexOf("posting.php") > 0) &&
          (location.search.indexOf("mode=edit") > 0) &&
          (location.search.indexOf("sanitise=1")) > 0)
    {

        var msgBox=document.getElementsByName("message")[0];              //Retrieve message box text
        var msgTxt=msgBox.innerHTML;

        msgTxt=msgTxt.replace(/http:\/\/([^\.]+)\./ig, "http://  .");     //Break http://
        msgTxt=msgTxt.replace(/www\./ig, "Cheese .");                     //Break www.
        msgBox.innerHTML=msgTxt;                                          //Replace text
        
        document.getElementById("disable_bbcode").checked=true;           //Disable BBCode
        document.getElementById("disable_smilies").checked=true;          //Disable Smileys
        document.getElementById("disable_magic_url").checked=true;        //Disable URL parsing
        document.getElementById("lock_post").checked=true;                //Lock post
        
        if (location.search.indexOf("autoSubmit=1") > 0)                  // If autoSubmit flag on, submit post
        {
            setTimeout("document.getElementById('postform').elements.namedItem('post').click()",1000)
        }
    }


//**************************************************
//threadMode()
//
//Setup script for viewtopic.php pages
//
//**************************************************
    function threadMode()
    {
        if(qMod && qReply)                                              //If quick mod select and quick reply elements exist
        {
            document.addEventListener("unload",removeListeners,false);  //Set unload event listener for listener cleanup
            setupThread()                                               //Call setup
        }

    }

//**************************************************
//setupThread()
//
//Creates UI (Thread Mode)
//
//**************************************************
    function setupThread()
    {
        createMoveSel()                                             //Create destination forum dropdown

        var br=document.createElement("br")                         //Create multiple-use elements
        var dd=document.createElement("dd")
        var dd2
        var span=document.createElement("span")
        var div=document.createElement("div")

        var button=document.createElement("input")                  //Create and configure template button element
        button.type="button"
        button.setAttribute("class","button1")
        button.style.paddingTop="3px"
        button.style.paddingBottom="3px"

        var h3=document.createElement("h3")                         //Create controls title element
        var titleText="Quick-Move Tool"
        h3.appendChild(document.createTextNode(titleText))

        var buttonDl=document.createElement("dl")                   //Create controls Dl container element
        buttonDl.id="buttonDl"


//--------------------------------------------
//Create container structure and append to
//document
//--------------------------------------------
        var controlDiv=div.cloneNode(true)                          //Create container div
        controlDiv.setAttribute("class","panel bg2")
	  controlDiv.style.textAlign="right"
        var div2=div.cloneNode(true)                                //Create inner div and append to control div
        div2.setAttribute("class","inner")
        controlDiv.appendChild(div2)
        
        var span2=span.cloneNode(true)                              //Create curved upper corners spans
        span2.setAttribute("class","corners-top")
        span2.appendChild(span.cloneNode(true))
        div2.appendChild(span2)                                     //Append to inner div

        var fieldset=document.createElement("fieldset")             //Create fieldset element
        fieldset.setAttribute("class","fields1")                    //Set class
        fieldset.appendChild(h3)                                    //Append title
        fieldset.appendChild(buttonDl)                              //Append controls Dl container element
        div2.appendChild(fieldset)
        
        var span2=span.cloneNode(true)                              //Create curved lower corners spans
        span2.setAttribute("class","corners-bottom")
        span2.appendChild(span.cloneNode(true))
        div2.appendChild(span2)                                     //Append to inner div

        postform.appendChild(controlDiv)                            //Append to postform element

//--------------------------------------------
        
        dd2=dd.cloneNode(true)                                      //Create dd element for destination forum dropdown
        dd2.appendChild(document.createTextNode("Move to:  "))      //Append text description
        dd2.appendChild(moveSel)                                    //Append destination forum dropdown
        buttonDl.appendChild(dd2)                                   //Append to controls Dl container element

//--------------------------------------------
        dd2=dd.cloneNode(true)                                      //Create dd element for shadow topic checkbox

        shadow=document.createElement("input")                      //Create shadow topic input checkbox
        shadow.id="move_leave_shadow"                               //Set id
        shadow.setAttribute("type","checkbox")                      //Set type to checkbox

        var label=document.createElement("label")                   //Create label for checkbox
        label.setAttribute("for","move_leave_shadow")               //Set for attribute and inner text
        label.appendChild(document.createTextNode("Leave Shadow Topic in place: "))
        label.appendChild(shadow)                                   //Append checkbox to label

        dd2.appendChild(label)                                      //Append label to dd element
        buttonDl.appendChild(dd2)                                   //Append dd element to controls Dl container element

//--------------------------------------------
        dd2=dd.cloneNode(true)                                      //Create dd element for buttons
        
        moveButton=button.cloneNode(true)                           //Create move button from template
        moveButton.id="moveButton"                                  //Set id, value, and inner HTML
        moveButton.value="Move"
        moveButton.innerHTML="Move"
        moveButton.addEventListener("click",moveClick,false);       //Set click listener
        moveButtonListener=true
        dd2.appendChild(moveButton)                                 //Append to dd element
        dd2.appendChild(document.createTextNode(" "))               //Append a separator space to the dd element
    
        replyButton=button.cloneNode(true)                          //Create reply button from template
        replyButton.id="replyButton"                                //Set id, value, and inner HTML
        replyButton.value="Move and Reply"
        replyButton.innerHTML="Move and Reply"
        replyButton.addEventListener("click",replyClick,false);     //Set click listener
        replyButtonListener=true
        dd2.appendChild(replyButton)                                //Append to dd element
        dd2.appendChild(document.createTextNode(" "))               //Append a separator space to the dd element
    
        buttonDl.appendChild(dd2)                                   //Append dd element to controls Dl container element
    
//--------------------------------------------
        moveMsg=dd.cloneNode(true)                                      //Create move message dd element
        moveMsg.id="moveMsg"                                            //Set id
        moveMsg.appendChild(document.createTextNode("Move Status: "))   //Append Move Status: test
        moveMsgVal=span.cloneNode(true)                                 //Create move message value span
        moveMsgVal.id="moveMsgVal"                                      //Set span id, default colour, and default value
        moveMsgVal.style.color="blue"
        moveMsgVal.innerHTML="Waiting..."
        moveMsg.appendChild(moveMsgVal)                                 //Append message value span to message dd element
        buttonDl.appendChild(moveMsg)                                   //Append message dd element to controls Dl container element

        replyMsg=dd.cloneNode(true)                                     //Create move message dd element
        replyMsg.id="replyMsg"                                          //Set id
        replyMsg.appendChild(document.createTextNode("Reply Status: ")) //Append Move Status: test
        replyMsgVal=span.cloneNode(true)                                //Create move message value span
        replyMsgVal.id="replyMsgVal"                                    //Set span id, default colour, and default value
        replyMsgVal.style.color="blue"
        replyMsgVal.innerHTML="Waiting..."
        replyMsg.appendChild(replyMsgVal)                               //Append message value span to message dd element
        buttonDl.appendChild(replyMsg)                                  //Append message dd element to controls Dl container element

//--------------------------------------------
//Create and append Edit Lock link

        var divs=document.getElementsByTagName("div")                   //Get all divs in page
        var i = 0
        var found = false
        var page1 = true


        //find pagination (page controls) div and page numbers span
        while (found == false)                                          //Cycle through all divs until correct div found
        {
            if(divs[i].getAttribute("class")=="pagination")             //If class = pagination, is page controls div
            {
                var found = true                                                          //Set loop exit flag (first post content div found)
                var pageNumberSpan = divs[i].getElementsByTagName("span")                 //Get first span elements in div (page numbers span)
                if (pageNumberSpan.length > 0)                                            //If at least one span element found
                {
                    if(pageNumberSpan[0].getElementsByTagName("a")[0].innerHTML == "1")   //If first link in span is to page 1, is not page 1 - do not create [Editlock] link
                    {
                        page1 = false
                    }
                }
            }
            i++
        }


        //find postbody div and append [Editlock] link, only if page 1
        if (page1 == true)
        {
            found = false
            i = 0
            while (found == false)                                          //Cycle through all divs until correct div found
            {
                if(divs[i].getAttribute("class")=="postbody")               //If class = postbody, is header/body (edit, quote, content etc.) component of post
                {
                    var found = true                                            //Set loop exit flag (first post content div found)

                    var li=document.createElement("li");                        //Create li element for Edit Lock link
                    editLockLink=document.createElement("a");                   //Create a element for Edit Lock link
                    editLockLink.addEventListener("click",editLockClick,false); //Set click listener
                    editLockLinkListener = true
                    editLockLink.id="editLockLink"                              //Set id
                    editLockLink.href="javascript:;"                            //Set href
                    editLockLink.innerHTML="[Editlock]"                         //Set text
                    li.appendChild(editLockLink)                                //append to li element

                    var ul=divs[i].getElementsByTagName("ul")[0]

                    ul.appendChild(li)                                      //Append li element to first ul element in post content div
                }
                i++
            }
            i--

    //--------------------------------------------
    //Find first Edit link
    
            var lis=divs[i].getElementsByTagName("li")                        //Get all link li tags in post body div
            var j = 0
            var found = false

            while (found == false)                                            //Cycle through all lis until correct li found
            {
                if(lis[j].getAttribute("class")=="edit-icon")                 //If class = edit-icon, is edit link li
                {
                    var found = true                                          //Set loop exit flag (first edit-icon li found)
                    editURL=lis[j].getElementsByTagName("a")[0].href          //Get Edit Post link
                }
                j++
            }

        }

//--------------------------------------------
//Create and append Sanitise link


        for (var i=0;i<divs.length;i++)                             //Cycle through all divs
        {
            if(divs[i].getAttribute("class")=="postbody")           //If class = postprofile, is post body (controls and content) component of post
            {
                var lis=divs[i].getElementsByTagName("li")          //Get all link li tags in post body div
                var found = false
                var j=0

                while ((found == false) && (j < lis.length))                //Cycle through all lis until correct li found
                {
                    if(lis[j].getAttribute("class")=="edit-icon")           //If class = edit-icon, is edit link li
                    {
                        var found = true                                    //Set loop exit flag (first edit-icon li found)
                        editURL2=lis[j].getElementsByTagName("a")[0].href   //Get Edit Post link

                        var li=document.createElement("li");                //Create li element for sanitise link
                        var a=document.createElement("a");                  //Create a element for sanitise link

                        //Set sanitise URL (edit + sanitise + autosubmit)
                        a.href=editURL2 +  "&sanitise=1" + "&autoSubmit=" + autoSubmit
                        a.innerHTML="[Sanitise]"                            //Set text
                        li.appendChild(a)                                   //append to li element

                        var ul=divs[i].getElementsByTagName("ul")[0]
                        ul.appendChild(li)                                  //Append li element to first ul element in post content div

                    }
                    j++                                                     //Go to next li element
                }
            }
        }


    }
 
//**************************************************
//createMoveSel()
//
//Copies jump to dropdown for destination forum dropdown
//
//**************************************************
    function createMoveSel()
    {
        moveSel=jumpTo.cloneNode(true)                          //Clone jumpTo dropdown node
        moveSel.id="moveSel"                                    //Set id
        moveSel.removeAttribute("name")                         //Remove name and onchange attributes
        moveSel.removeAttribute("onchange")
        var opts=moveSel.options                                //Retrieve options elements
        for(var i=0;i<opts.length;i++)                          //Cycle through options elements
        {
            if(opts[i].value=="26")                             //If option element value = 26 (locked posts)
                opts[i].setAttribute("selected","selected")     //Set selected attribute
            
            else
                opts[i].removeAttribute("selected")             //Else remove selected attribute
        }
    }

//**************************************************
//editLockClick()
//
//Called by Edit Lock link click event
//Sets Quick Reply box to "Spam", opens post
//edit in a new tab, and starts move and reply
//process
//
//**************************************************
    function editLockClick()
    {
        //Set post content = Spam
        document.getElementById("message").value= "[img]http://img411.imageshack.us/img411/3163/spamkb.jpg[/img]"
        //Edit Post in new tab
        GM_openInTab(editURL + "&sanitise=" + sanitise + "&autoSubmit=" + autoSubmit)

        //Select Locked Posts to move thread to
        var opts=moveSel.options                                //Retrieve options elements
        for(var i=0;i<opts.length;i++)                          //Cycle through options elements
        {
            if(opts[i].value=="26")                             //If option element value = 26 (locked posts)
                opts[i].setAttribute("selected","selected")     //Set selected attribute
            
            else
                opts[i].removeAttribute("selected")             //Else remove selected attribute
        }
        
        replyClick()                                          //Move & Reply
    }

//**************************************************
//moveClick()
//
//Called by move button click event
//starts move process
//
//**************************************************
    function moveClick()
    {
        action="move"       //Set action = move
        disableButtons()    //Disable buttons
        createMoveFrame()   //Create move frame
        updateMsgs()        //Update messages
    }

//**************************************************
//replyClick()
//
//Called by move & reply button click event
//validates reply then starts move and reply process
//
//**************************************************
    function replyClick()
    {
        if(document.getElementById("message").value.length <= 2)        //If message too short, display error message
            alert("Your message contains too few characters.")

        else                                                            //else
        {
            action="reply"                                              //Set action = reply
            disableButtons()                                            //Disable buttons
            createMoveFrame()                                           //Create move frame
            createReplyFrame()                                          //Create reply frame
            updateMsgs()                                                //Update messages
        }
    }

//**************************************************
//disableButtons()
//
//Called on move and move & reply button clicks,
//if reply valid. Disables controls
//
//**************************************************
    function disableButtons()
    {
        moveButton.setAttribute("disabled","disabled")              //Disable move button
        moveButton.style.color="rgb(128,128,128)"                   //Set text colour to mid grey
        replyButton.setAttribute("disabled","disabled")             //Disable reply button
        replyButton.style.color="rgb(128,128,128)"                  //Set text colour to mid grey
        moveSel.setAttribute("disabled","disabled")                 //Disable destination forum dropdown
        shadow.setAttribute("disabled","disabled")                  //Disable shadow topic checkbox

        if(moveButtonListener==true)
        {                                                           //If move button click listener on, remove it
            moveButton.removeEventListener("click",moveClick,false);
            moveButtonListener=false
        }
        if(replyButtonListener==true)
        {                                                           //If reply button click listener on, remove it
            replyButton.removeEventListener("click",moveClick,false);
            replyButtonListener=false
        }
    }

//**************************************************
//createMoveFrame()
//
//Called on move and move & reply button clicks,
//if reply valid. Creates move frame
//
//**************************************************
    function createMoveFrame()
    {
        moveFrame=document.createElement("iframe");                     //Create move frame
        moveFrame.addEventListener("load",moveFrameLoad,false);         //Set load listener
        moveFrame.width="0";                                            //Set size and border to 0
        moveFrame.height="0";
        moveFrame.style.border="0";
        moveFrame.style.visibility="hidden;";                           //Hide frame
        moveFrameListener=true;
        moveFrame.setAttribute("id","moveIframe");                      //Set frame id
        moveFrame.setAttribute("name","moveIframe");                    //set frame name
        //Set src as data url of source
        moveFrame.src="data:text/html;charset=utf-8,%3C!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"%3E%0A%0A%3Chtml xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en-gb\" xml:lang=\"en-gb\"%3E%0A%3Chead%3E%0A    %3Cmeta content=\"text/html; charset=ISO-8859-1\" http-equiv=\"content-type\" /%3E%0A    %3Ctitle%3EtestMove%3C/title%3E%0A%3C/head%3E%0A%3Cbody%3E%0A%0A%3Cform id=\"initMoveForm\" method=\"post\" action=\"\"%3E%0A    %3Cfieldset class=\"quickmod\" style=\"\"%3E%0A		%3Clabel for=\"quick-mod-select\"%3EQuick-mod tools:%3C/label%3E%0A		%3Cselect name=\"action\" id=\"quick-mod-select\"%3E%3Coption value=\"move\"%3EMove topic%3C/option%3E%3C/select%3E%0A		%3Cinput value=\"Go\" class=\"button2\" type=\"submit\" id=\"submitButton\"%3E%0A		%3Cinput name=\"creation_time\" value=\"\" type=\"hidden\"%3E%0A        %3Cinput name=\"form_token\" value=\"\" type=\"hidden\"%3E%0A	%3C/fieldset%3E%0A%3C/form%3E%0A%0A%3C/body%3E%0A%3C/html%3E"

        qReply.appendChild(moveFrame);                                  //Append to document
        moveState=2                                                     //move state = 2 (initial load)
    }

//**************************************************
//createReplyFrame()
//
//Called on move & reply button clock, if reply
//valid. Creates reply frame
//
//**************************************************
    function createReplyFrame()
    {
        replyFrame=document.createElement("iframe");                    //Create reply frame
        replyFrame.addEventListener("load",replyFrameLoad,false);       //Set load listener
        replyFrameListener=true;
        replyFrame.setAttribute("id","replyIframe");                    //Set frame id
        replyFrame.setAttribute("name","replyIframe");                  //set frame name
        //Set src as data url of source
        replyFrame.src="data:text/html;charset=utf-8,%3C!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"%3E%0A%0A%3Chtml xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en-gb\" xml:lang=\"en-gb\"%3E%0A%3Chead%3E%0A    %3Cmeta content=\"text/html; charset=ISO-8859-1\" http-equiv=\"content-type\" /%3E%0A    %3Ctitle%3EtestReply%3C/title%3E%0A%3C/head%3E%0A%3Cbody%3E%0A%0A%3Cform action=\"./posting.php?sid=f58da068ef45db0a5b4589e300934178\" method=\"post\" id=\"postform\" name=\"postform\"%3E%0A%0A    %3Cfieldset class=\"fields1\" style=\"width:90%; margin-left:auto;margin-right:auto;padding-top:10px;\"%3E%0A        %3Cinput type=\"hidden\" name=\"subject\" value=\"\" /%3E%0A        %3Ctextarea name=\"message\" id=\"message\" rows=\"7\" cols=\"90\" tabindex=\"2\" onselect=\"storeCaret(this);\" class=\"inputbox\" style=\"width:100%\"%3E%3C/textarea%3E%0A        %3Clabel for=\"attach_sig\"%3E%3Cinput type=\"checkbox\" name=\"attach_sig\" id=\"attach_sig\" checked=\"checked\" /%3E Attach a signature (signatures can be altered via the UCP)%3C/label%3E%0A        %3Clabel for=\"quote_last_msg\"%3E%3Cinput type=\"checkbox\" name=\"quote_last_msg\" id=\"quote_last_msg\" /%3E Quote the last message%3C/label%3E         %0A        %3Clabel for=\"notify\"%3E%3Cinput type=\"checkbox\" name=\"notify\" id=\"notify\" /%3E Notify me when a reply is posted%3C/label%3E%0A    %3C/fieldset%3E%0A%0A    %3Cfieldset class=\"submit-buttons\"%3E%0A        %3Cinput type=\"hidden\" name=\"t\" value=\"\" /%3E%0A        %3Cinput type=\"hidden\" name=\"f\" value=\"\" /%3E%0A        %3Cinput type=\"hidden\" name=\"mode\" value=\"reply\" /%3E%0A        %3Cinput type=\"hidden\" name=\"lastclick\" value=\"\" /%3E%0A        %3Cinput type=\"hidden\" name=\"icon\" value=\"0\" /%3E%0A        %3Cinput type=\'hidden\' name=\'last_post\' value=\"\" /%3E%0A        %3Cinput type=\"submit\" name=\"post\" value=\"Submit\" id=\"submitButton\" class=\"button1\" /%3E%0A    %3C/fieldset%3E%0A      %0A    %3Cinput type=\"hidden\" name=\"creation_time\" value=\"\" /%3E%0A    %3Cinput type=\"hidden\" name=\"form_token\" value=\"\" /%3E%0A    %0A%3C/form%3E%0A%0A%3C/body%3E%0A%3C/html%3E";
        replyFrame.width="0";                                           //Set size and border to 0
        replyFrame.height="0";
        replyFrame.style.border="0";
        replyFrame.style.visibility="hidden;";                          //Hide frame
        qReply.appendChild(replyFrame);                                 //Append to document
        replyState=2                                                    //Reply state = 2 (initial load)
    }

//**************************************************
//replyFrameLoad()
//
//Called by load event for reply iframe, performs
//actions based on reply state
//
//**************************************************
    function replyFrameLoad()
    {
        if(replyFrameFinal)                                                                             //If reply frame final load flag set
        {
            replyFrame.addEventListener("load",replyFrameLoad,false);                                   //Remove reply frame load listener
            replyFrameListener=true;
            replyFrame.parentNode.removeChild(replyFrame)                                               //Remove reply frame
            finalisation()                                                                              //Call finalisation
        }

        else if(replyState==2)                                                                          //Else if reply state=2, frame is reply submit form (initial frame load complete)
        {
            replyFrameForm=replyFrame.contentDocument.getElementById("postform")                        //Get reply frame form

            var url=postform.getAttribute("action")                                                     //Retrieve page reply form action attribute
            url=document.location.protocol+"//"+document.location.hostname+url.substr(1)                //Set full action url
            replyFrameForm.setAttribute("action",url)                                                   //Update frame reply form action attribute

            //Update frame form elements from page form elements
            replyFrameForm.elements.namedItem("subject").value=postform.elements.namedItem("subject").value
            replyFrameForm.elements.namedItem("message").value=postform.elements.namedItem("message").value
            replyFrameForm.elements.namedItem("attach_sig").checked=postform.elements.namedItem("attach_sig").checked
            replyFrameForm.elements.namedItem("quote_last_msg").checked=postform.elements.namedItem("quote_last_msg").checked
            replyFrameForm.elements.namedItem("notify").checked=postform.elements.namedItem("notify").checked
            replyFrameForm.elements.namedItem("t").value=postform.elements.namedItem("t").value
            replyFrameForm.elements.namedItem("f").value=postform.elements.namedItem("f").value
            replyFrameForm.elements.namedItem("lastclick").value=postform.elements.namedItem("lastclick").value
            replyFrameForm.elements.namedItem("last_post").value=postform.elements.namedItem("last_post").value
            replyFrameForm.elements.namedItem("creation_time").value=postform.elements.namedItem("creation_time").value
            replyFrameForm.elements.namedItem("form_token").value=postform.elements.namedItem("form_token").value

            replyFrame.contentDocument.getElementById("submitButton").click()                           //Submit reply frame
            replyState=3                                                                                //set reply state = 3 (awaiting response from reply request)
        }

        else if(replyState==3)                                                                          //Else if reply state = 3, frame is result page for reply request
        {
            loadCount=loadCount-1                                                                       //Increment frame load count (for history fixing)
            try
            {
                var response=replyFrame.contentDocument.getElementById("message").innerHTML             //Try to access innerhtml of message id element in frame
            }
            catch(e)
            {
                var response=""                                                                         //If error on access, set response to empty
            }
            
            if(response.indexOf("posted successfully")!=-1)                                             //If response includes text "posted successfully"
                replyState=5                                                                            //move status = 5 (successful)
            else
                replyState=0                                                                            //else reply status = 0 (failed)

            replyFrame.src="about:blank"                                                                //Frame has finished loading, so set frame to about:blank
        }

        else if(replyState==0||replyState==5)                                                           //Else if reply state = 0 or 5, reply operation is finished
        {
            loadCount=loadCount-1                                                                       //Increment frame load count (for history fixing)
            fixHistory()                                                                                //Call fix history to back up through frame loads in history
        }

        updateMsgs()                                                                                    //Update messages

    }

//**************************************************
//moveFrameLoad()
//
//Called by load event for move iframe, performs
//actions based on move state
//
//**************************************************
    function moveFrameLoad()
    {
        if(moveFrameFinal)                                                                              //If move frame final load flag set
        {
            moveFrame.removeEventListener("load",moveFrameLoad,false);                                  //Remove frame load listener
            moveFrameListener=false;
            moveFrame.parentNode.removeChild(moveFrame)                                                 //Remove frame
            finalisation()                                                                              //Call finalisation
        }

        else if(moveState==2)                                                                           //Else if movestate=2, frame is quick mod submit form (initial frame load complete)
        {
            moveFrame.contentDocument.getElementsByName("creation_time")[0].value=creationTime          //Update creation_time & form_token fields in frame from page
            moveFrame.contentDocument.getElementsByName("form_token")[0].value=formToken

            var qModForm=qMod
            while(true)                                                                                 //Cycle through parent nodes from quick_mod_select element
            {
                qModForm=qModForm.parentNode                                                            //Get parent node
                if(qModForm.nodeName.toLowerCase()=="form")                                             //If node is a form element
                {
                    var url=qModForm.getAttribute("action")                                             //Get its action attribute
                    url=document.location.protocol+"//"+document.location.hostname+url.substr(1)        //Generate full action url
                    moveFrame.contentDocument.getElementById("initMoveForm").setAttribute("action",url) //Set action attribute of iframe form
                    moveFrame.contentDocument.getElementById("submitButton").click()                    //Submit quick mod iframe form
                    moveState=3                                                                         //Move state=3 (loading iframe move form)
                    break;                                                                              //End loop cycle
                }
            }
        }
        else if(moveState==3)                                                                           //Else if movestate=3, frame is move form
        {
            loadCount=loadCount-1                                                                       //Increment frame load count (for history fixing)
            var targForum=moveSel.options[moveSel.selectedIndex].value                                  //Get selected target forum
            var opts=moveFrame.contentDocument.getElementsByName("to_forum_id")[0].options              //Get options elements from iframe move form
            for(var i=0;i<opts.length;i++)                                                              //Cycle through options elements
            {
                if(opts[i].value==targForum)                                                            //If current option = target
                    opts[i].setAttribute("selected","selected")                                         //Set selected attribute
                
                else
                    opts[i].removeAttribute("selected")                                                 //Else remove selected attribute
            }
            var checked=document.getElementById("move_leave_shadow").checked                            //Get shadow topic option
            moveFrame.contentDocument.getElementById("move_leave_shadow").checked=checked               //Set iframe move form shadow topic option to match
            moveFrame.contentDocument.getElementsByName("confirm")[0].click()                           //Submit iframe move form
            moveState=4                                                                                 //Move state=4 (awaiting response from move request)
            
        }
        else if(moveState==4)                                                                           //Else if movestate=4, frame is result page for move request
        {
            loadCount=loadCount-1                                                                       //Increment frame load count (for history fixing)
            try
            {
                var response=moveFrame.contentDocument.getElementById("message").innerHTML              //Try to access innerhtml of message id element in frame
            }
            catch(e)
            {
                var response=""                                                                         //If error on access, set response to empty
            }
            
            if(response.indexOf("moved successfully")!=-1)                                              //If response includes text "moved successfully"
                moveState=5                                                                             //move state = 5 (move sucessful)
            else
                moveState=0                                                                             //Else move state = 0 (move failed)

            moveFrame.src="about:blank"                                                                 //Frame has finished loading, so set frame to about:blank
        }
        else if(moveState==0||moveState==5)                                                             //Else if movestate = 0 or 5, move operation is finished
        {
            loadCount=loadCount-1                                                                       //Increment frame load count (for history fixing)
            fixHistory()                                                                                //Call fix history to back up through frame loads in history
        }

        updateMsgs()                                                                                    //Update messages
    }
    
//**************************************************
//updateMsgs()
//
//Update status messages based on move/reply state
//and action
//
//**************************************************
    function updateMsgs()
    {
        if(action=="move")
            replyMsg.style.visibility="hidden";
        else
            replyMsg.style.visibility="block";

        switch(moveState)
        {
            case 1:
            moveMsgVal.style.color="blue"
            moveMsgVal.innerHTML="Waiting..."
            break;
            
            case 2:
            moveMsgVal.style.color="orange"
            moveMsgVal.innerHTML="Loading Form..."
            break;
            
            case 3:
            moveMsgVal.style.color="orange"
            moveMsgVal.innerHTML="Submitting Request..."
            break;
            
            case 4:
            moveMsgVal.style.color="orange"
            moveMsgVal.innerHTML="Awaiting Response..."
            break;
            
            case 5:
            moveMsgVal.style.color="green"
            moveMsgVal.innerHTML="Move Successful."
            break;
            
            case 0:
            moveMsgVal.style.color="red"
            moveMsgVal.innerHTML="Move Failed."
            break;

        }
        switch(replyState)
        {
            case 1:
            replyMsgVal.style.color="blue"
            replyMsgVal.innerHTML="Waiting..."
            break;
            
            case 2:
            replyMsgVal.style.color="orange"
            replyMsgVal.innerHTML="Submitting Request..."
            break;
            
            case 3:
            replyMsgVal.style.color="orange"
            replyMsgVal.innerHTML="Awaiting Response..."
            break;
            
            case 5:
            replyMsgVal.style.color="green"
            replyMsgVal.innerHTML="Reply Successful."
            break;
            
            case 0:
            replyMsgVal.style.color="red"
            replyMsgVal.innerHTML="Reply Failed."
            break;

        }
    }


//**************************************************
//fixHistory()
//
//Called by each frame load function if operation
//has completed (success state=5, fail state=0)
//
//Navigates back through all frame loads in history
//
//**************************************************
    function fixHistory()
    {
        //If    reply and move operations finished                              or   move finished and action = move only
        if (  ((replyState==0||replyState==5)&&(moveState==0||moveState==5))    ||  (action=="move"&&(moveState==0||moveState==5))  )
        {
            document.body.focus()           //focus document body

            moveFrameFinal=true             //Set move frame final load flag
            if(action=="reply")
                replyFrameFinal=true        //If action = reply, set reply frame final load flag

            history.go(loadCount);          //Move back through history once for each frame load occurence
        }

    }

//**************************************************
//finalisation()
//
//Called by each frame load function when final load
//completed
//
//Removes event listeners and redirects to forum
//
//**************************************************
    function finalisation()
    {
        //If    reply and move operations finished                              or   move finished and action = move only
        if (  ((replyState==0||replyState==5)&&(moveState==0||moveState==5))    ||  (action=="move"&&(moveState==0||moveState==5))  )
            removeListeners()                                   //Remove event listeners
        
        if(moveState==5 && (replyState==5||action=="move"))     //If operation successful
            document.location.href=redir                        //Redirect

    }

//**************************************************
//removeListeners()
//
//Removes event listeners
//
//**************************************************
    function removeListeners()
    {
        document.removeEventListener("unload",removeListeners,false);       //Remove unload listener

        if(replyButtonListener)
            replyButton.removeEventListener("click",replyClick,false);      //If enabled, remove reply button listener

        if(moveButtonListener)
            moveButton.removeEventListener("click",moveClick,false);        //If enabled, remove move button listener

        if(replyFrameListener)
            replyFrame.removeEventListener("load",replyFrameLoad,false);    //If enabled, remove reply frame listener

        if(moveFrameListener)
            moveFrame.removeEventListener("load",moveFrameLoad,false);      //If enabled, remove move frame listener

        if(editLockLinkListener)
            editLockLink.removeEventListener("click",editLockClick,false);  //If enabled, remove Edit Lock Link listener

    }

})();


Re: greasemonkey script issue

Posted: Sun Oct 10, 2010 6:46 pm
by Guest
Note that is script is specifically for use at mozillazine, not a general php script. I suspect it will need a fair amount of work to get it working here.

Re: greasemonkey script issue

Posted: Sun Oct 17, 2010 8:39 pm
by Guest
No solution to this problem? Also, where do I find the "NoScript Blocked Objects submenu"?

Re: greasemonkey script issue

Posted: Sun Oct 17, 2010 8:50 pm
by Giorgio Maone
Guest wrote:No solution to this problem?
Unfortunately, not yet.
Guest wrote:Also, where do I find the "NoScript Blocked Objects submenu"?
It's a submenu of the main NoScript menu, and its label is "Blocked Objects".

Re: greasemonkey script issue

Posted: Mon Oct 18, 2010 1:52 pm
by therube
It's a submenu of the main NoScript menu, and its label is "Blocked Objects".
And it also only appears when there's a reason for it to - like when there are blocked objects.
IOW, you may not see it all the time.

Re: greasemonkey script issue

Posted: Mon Oct 18, 2010 11:43 pm
by lou-noise
therube wrote:
It's a submenu of the main NoScript menu, and its label is "Blocked Objects".
And it also only appears when there's a reason for it to - like when there are blocked objects.
IOW, you may not see it all the time.
Thanks, I was baffled about where to find it.

Is there anyway to simply allow all objects from mozillazine? What was a handy and powerful tool isn't any more.

Re: greasemonkey script issue

Posted: Thu Oct 28, 2010 11:40 pm
by Noise,Loudnoise
Registered. Just bumping to get my name attached to it.