// ==UserScript==
// @name            Report Spam to SpamCop
// @namespace       http://www.spamcop.net/
// @description     Auto Process Spam Reporting
// @include         http://www.spamcop.net/sc?id=*
// ==/UserScript==

// Automating the spamcop reporting process (as much as makes sense)
// 3-step spam report: review junk, click on Okopipi frog +Send, open all links

// This will automatically click the Report Spam button and close the tab 
// of a spamcop "finish spam reporting". I found script here: (without tab closing)
//  http://blog.coomanskristof.be/2006/07/06/spamcop-reporting-bookmarklet/ 
// I grabbed the tab closing from somewhere else on the web.
 
// Use together with thunderbird extension to open all links:
//  http://blog.coomanskristof.be/2006/07/14/open_all_links/
//  https://addons.mozilla.org/firefox/2913/
// and Thunderbird Okipipi extension:
//  https://addons.mozilla.org/thunderbird/2672/

(function(){

    var forms=document.getElementsByName('sendreport');
    if(forms.length==1) {
        forms[0].submit();
    }

    // Now close Firefox tab
    function closeWindow() {
        //alert("close window");
        // fool browser into thinking it was opened by script
        // (doesn't work with later versions Firefox :( )
        window.open('','_parent','');
        window.close();
        //alert("close window after ?");
// watch out for Firefox security settings, error:
// Scripts may not close windows that were not opened by script.
// Tools->Options-> Content[Tab] -> Javascript .. Advanced -> Allow scripts to raise/lower windows :-7
// and use NoScript plugin >;)  
    }
    //alert("close window");
    //closeWindow();

        //window.close();
//alert("close");
//close();
//alert("top.close");
      //top.close();
  // http://www.google.ie/search?q=greasemonkey+%22Scripts+may+not+close+windows+that+were+not+opened+by+script.%22&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

//alert("window.opener.close()");
//window.opener = window; window.close();

// DAMN!   okay Ctrl-W Ctrl-W Ctrl-W   or  MultipleTabHandler maybe
parent.close();

//alert("window.open _self");
//window.open("javascript:window.close();","_self","");

//alert("after all");
}
)();
