Conquer Club

Script: Team PM - Version 1.0.1

The home of third-party tools and utilities that can enhance your Conquer Club experience.

Moderator: Tech Team

Forum rules
Please read the Community Guidelines before posting.

Re: Script: Team PM - Version 1.0.0

Postby dgz345 on Tue Aug 26, 2014 4:15 pm

I'll be able to check and confirm this bug. And then hopefully find what's wrong and mend it.
User avatar
Lieutenant dgz345
Head Tech
Head Tech
 
Posts: 1081
Joined: Thu Oct 07, 2010 10:53 am
Medals: 50
Standard Achievement (3) Doubles Achievement (2) Triples Achievement (2) Quadruples Achievement (2) Terminator Achievement (1)
Assassin Achievement (1) Manual Troops Achievement (2) Freestyle Achievement (2) Polymorphic Achievement (1) Nuclear Spoils Achievement (1)
Fog of War Achievement (3) Trench Warfare Achievement (2) Speed Achievement (1) Teammate Achievement (1) Random Map Achievement (2)
Cross-Map Achievement (3) Beta Map Achievement (1) Ratings Achievement (4) Tournament Achievement (2) General Achievement (4)
Clan Achievement (5) Challenge Achievement (2) General Contribution (3)

Re: Script: Team PM - Version 1.0.0

Postby RobbieDub on Tue Aug 26, 2014 6:05 pm

thanks I turned assault odds back on and it isn't doing the crazy stuff but I have left the other two off especially since chatglove is acting a little funny anyways.
Thanks for all the work you do with the scripts dgz
Highest Rank Colonel with 2932
Image
User avatar
Colonel RobbieDub
 
Posts: 359
Joined: Fri Aug 21, 2009 1:12 am
Location: Salt Spring Island
Medals: 70
Standard Achievement (3) Doubles Achievement (3) Triples Achievement (3) Quadruples Achievement (3) Terminator Achievement (2)
Assassin Achievement (1) Manual Troops Achievement (2) Freestyle Achievement (2) Nuclear Spoils Achievement (2) Fog of War Achievement (4)
Trench Warfare Achievement (2) Speed Achievement (2) Teammate Achievement (2) Random Map Achievement (3) Cross-Map Achievement (4)
Beta Map Achievement (2) Ratings Achievement (4) Tournament Achievement (11) General Achievement (3) Clan Achievement (12)

Re: Script: Team PM - Version 1.0.0

Postby RobbieDub on Tue Oct 21, 2014 10:44 am

I'm still having trouble when I use the Team PM script. It stops the panel interface from updating my moves during a turn resulting in the snapshot at the end of my turn being the look of the map at the start of my turn. Also if I want to fort it shows the territories I have taken as still being owned by the other player although I can still fort to it.
Highest Rank Colonel with 2932
Image
User avatar
Colonel RobbieDub
 
Posts: 359
Joined: Fri Aug 21, 2009 1:12 am
Location: Salt Spring Island
Medals: 70
Standard Achievement (3) Doubles Achievement (3) Triples Achievement (3) Quadruples Achievement (3) Terminator Achievement (2)
Assassin Achievement (1) Manual Troops Achievement (2) Freestyle Achievement (2) Nuclear Spoils Achievement (2) Fog of War Achievement (4)
Trench Warfare Achievement (2) Speed Achievement (2) Teammate Achievement (2) Random Map Achievement (3) Cross-Map Achievement (4)
Beta Map Achievement (2) Ratings Achievement (4) Tournament Achievement (11) General Achievement (3) Clan Achievement (12)

Re: Script: Team PM - Version 1.0.0

Postby conrwronski on Sat Oct 25, 2014 9:48 am

use Internet explorer or Chrome to have it work right, have some other glitched with IE so I now use Chrome for CC games.
User avatar
Major conrwronski
 
Posts: 8
Joined: Sun Nov 06, 2011 11:01 pm
Medals: 40
Standard Achievement (2) Doubles Achievement (2) Triples Achievement (2) Quadruples Achievement (2) Terminator Achievement (1)
Manual Troops Achievement (1) Freestyle Achievement (1) Nuclear Spoils Achievement (1) Fog of War Achievement (3) Trench Warfare Achievement (1)
Teammate Achievement (1) Random Map Achievement (2) Cross-Map Achievement (2) Ratings Achievement (4) General Achievement (1)
Clan Achievement (14)

Re: Script: Team PM - Version 1.0.0

Postby The_Samurai on Sat Oct 25, 2014 2:32 pm

I confirm that it works smoothly with Chrome.
Image
Best rank: Brigadier - ranked #45 | high score 3306 | 6 August 2015 | Games won 811 (52%)
Co-leader of Retribution
User avatar
Colonel The_Samurai
 
Posts: 416
Joined: Wed Nov 17, 2010 7:38 am
Location: South Africa
Medals: 50
Standard Achievement (2) Doubles Achievement (2) Triples Achievement (2) Quadruples Achievement (3) Terminator Achievement (1)
Assassin Achievement (1) Manual Troops Achievement (1) Freestyle Achievement (1) Polymorphic Achievement (1) Nuclear Spoils Achievement (1)
Fog of War Achievement (3) Trench Warfare Achievement (2) Speed Achievement (1) Teammate Achievement (2) Random Map Achievement (2)
Cross-Map Achievement (3) Beta Map Achievement (1) Ratings Achievement (3) Tournament Achievement (1) Clan Achievement (17)

Re: Script: Team PM - Version 1.0.0

Postby judge_reinhold on Wed Dec 24, 2014 11:25 pm

The script is mangling the subject line of messages. It also has the entire jquery library (many kilobytes) copied into it.

So I fixed the subject line bug and removed jquery from the code and instead added a "@require" to the top of the script. Whoever is in charge of this, here you go. Free service from me.


// ==UserScript==
// @name Conquer Club - Team PM
// @version 1.0.1
// @namespace http://tools.conquerclub.com/
// @description Adds a button in team games to private message entire team
// @author ThrushAAX, edited by Foxglove. edited 20141224 as a Christmas gift from jr
// @require http://code.jquery.com/jquery-latest.js
// @include http://www.conquerclub.com/game.php?game=*
// @include https://www.conquerclub.com/game.php?game=*
// @match *://*.conquerclub.com/game.php?game=*
// ==/UserScript==

var gamenumber = 0;
var username = null;

if(/www.conquerclub.com\/game.php\?game=(\d+)/.test(window.location.href) ){
gamenumber = RegExp.$1;

if(gamenumber){
$.get("/api.php", {
mode: "gamelist",
gn: gamenumber
}, doWork, "xml");
}
}

function getMyName(){
if(username) return username;

username = $("#this_username").text();

return username;
}

function doWork(xml){

var $xml = $(xml);

if( $xml.find("games").attr("total") != "1"){ //should only have 1 game so pretty big problem otherwise
return;
}

var $game = $xml.find("game");

//get type
var type = $game.children("game_type").text();
var teamsize;

if( type == 'Q' ){
teamsize = 4;
type = 'quadruples';
}
else if( type == 'T'){
teamsize = 3;
type = 'triples';
}
else if( type == 'D'){
teamsize = 2;
type = 'doubles';
}
else { // some other type we don't care about
return;
}

//get players ids
var playerids = [];
var myindex = -1;

for(var i = 1; i <= 12; i++){
var a = $("#stat_rank_"+i);

if( !a.length){ // didn't find the item, so no more players
break;
}

if(/u=(\d+)/.test( a.attr("href") )){
playerids.push(RegExp.$1);

var playername = $("#stat_player_"+i).text().split(":")[1];

if(playername == getMyName() ){
myindex = i - 1;
}
}
}

if( myindex < 0){ // I'm not in this game!
return;
}

var mapname = $game.children("map").text();
var myid = playerids[myindex];
var startindex;

//if( teamsize == 2 ){ //handle doubles
// startindex = (Math.floor(myindex / 2) * 2);
//}
//else { //handle tripples and quads
// startindex = myindex < teamsize ? 0 : teamsize;
//}
startindex = myindex < teamsize ? 0 : (Math.floor(myindex / teamsize) * teamsize);

// get the ids of the people in your team excluding yourself
var teamplayers = playerids.splice(startindex,teamsize);
teamplayers.splice(teamplayers.indexOf(myid),1);

var tourneyname = ''; // added by jr
if($("#tournament_info").length > 0 ) { // added by jr
tourneyname = $("#tournament_info span a").text();
}

// var tourneyname = $("#dashboard").find("td:contains(Tournament:)").find("a").text(); // commented by jr
var subject = mapname+' ';
if( tourneyname ){
subject += 'for '+tourneyname;
}
else {
subject += type;
}
subject = subject.substring(0,60); //max length for subjects

//make fake post form to add users to pm form
var form='<form id="PMTEAMFORM" method="post" target="_blank" action="/forum/ucp.php?i=pm&mode=compose">';

for( var i = 0; i < teamplayers.length - 1; i++){
form += '<input type="hidden" name="address_list[u]['+ teamplayers[i] +']" value="to"/>';
}

// required to get form not to give error..
form += '<input type="hidden" name="add_to['+teamplayers[teamplayers.length-1] +']" value="Add"/>';

form += '<input type="hidden" name="subject" value="'+subject+'"/>'
form += '<input type="hidden" name="message" value="[Game]'+gamenumber+'[/Game]"/>'
form += '<input type="submit" name="" value="" style="display:none;" />'
form += '</form>';


$('<button>PM Teammates</button>').insertAfter("#players").click(function(){
var evt = document.createEvent("HTMLEvents");
evt.initEvent("submit", true, true);
// tries to submit the form in two different ways for chrome and FF
$(form).insertAfter("#chat-form").submit().get(0).dispatchEvent(evt);
});

}
User avatar
Captain judge_reinhold
 
Posts: 90
Joined: Sun Sep 02, 2012 10:59 pm
Location: meat
Medals: 21
Standard Achievement (2) Doubles Achievement (1) Triples Achievement (1) Quadruples Achievement (1) Manual Troops Achievement (1)
Polymorphic Achievement (1) Nuclear Spoils Achievement (1) Fog of War Achievement (2) Trench Warfare Achievement (2) Teammate Achievement (1)
Random Map Achievement (1) Cross-Map Achievement (1) Ratings Achievement (3) Tournament Achievement (1) Clan Achievement (2)

Re: Script: Team PM - Version 1.0.0

Postby dgz345 on Thu Dec 25, 2014 12:53 pm

judge_reinhold wrote:The script is mangling the subject line of messages. It also has the entire jquery library (many kilobytes) copied into it.

So I fixed the subject line bug and removed jquery from the code and instead added a "@require" to the top of the script. Whoever is in charge of this, here you go. Free service from me.

Code: Select all
// ==UserScript==
// @name          Conquer Club - Team PM
// @version       1.0.1
// @namespace     http://tools.conquerclub.com/
// @description   Adds a button in team games to private message entire team
// @author        ThrushAAX, edited by Foxglove. edited 20141224 as a Christmas gift from jr
// @require http://code.jquery.com/jquery-latest.js
// @include       http://www.conquerclub.com/game.php?game=*
// @include       https://www.conquerclub.com/game.php?game=*
// @match         *://*.conquerclub.com/game.php?game=*
// ==/UserScript==

var gamenumber = 0;
var username = null;

if(/www.conquerclub.com\/game.php\?game=(\d+)/.test(window.location.href) ){
    gamenumber = RegExp.$1;

    if(gamenumber){
        $.get("/api.php", {
            mode: "gamelist",
            gn: gamenumber
        }, doWork, "xml");
    }
}

function getMyName(){
    if(username) return username;
   
    username = $("#this_username").text();
   
    return username;
}

function doWork(xml){
   
    var $xml = $(xml);
   
    if( $xml.find("games").attr("total") != "1"){   //should only have 1 game so pretty big problem otherwise
        return;
    }
   
    var $game = $xml.find("game");

    //get type
    var type = $game.children("game_type").text();
    var teamsize;
   
    if( type == 'Q' ){
        teamsize = 4;
        type = 'quadruples';
    }
    else if( type == 'T'){
        teamsize = 3;
        type = 'triples';
    }
    else if( type == 'D'){
        teamsize = 2;
        type = 'doubles';
    }
    else { // some other type we don't care about
        return;
    }
   
    //get players ids
    var playerids = [];
    var myindex = -1;
   
    for(var i = 1; i <= 12; i++){
        var a = $("#stat_rank_"+i);
       
        if( !a.length){ // didn't find the item, so no more players
            break;
        }
       
        if(/u=(\d+)/.test( a.attr("href") )){
            playerids.push(RegExp.$1);
           
            var playername = $("#stat_player_"+i).text().split(":")[1];
       
            if(playername == getMyName() ){
                myindex = i - 1;
            }
        }
    }   
   
    if( myindex < 0){      // I'm not in this game!
        return;
    }
   
    var mapname = $game.children("map").text();
    var myid = playerids[myindex];
    var startindex;
   
    //if( teamsize == 2 ){   //handle doubles
    //    startindex = (Math.floor(myindex / 2) * 2);
    //}
    //else {  //handle tripples and quads
    //    startindex = myindex < teamsize ? 0 : teamsize;
    //}
    startindex = myindex < teamsize ? 0 : (Math.floor(myindex / teamsize) * teamsize);
   
    // get the ids of the people in your team excluding yourself
    var teamplayers = playerids.splice(startindex,teamsize);
    teamplayers.splice(teamplayers.indexOf(myid),1);
   
    var tourneyname = ''; // added by jr
    if($("#tournament_info").length > 0 ) { // added by jr
       tourneyname = $("#tournament_info span a").text();
    }
   
    // var tourneyname = $("#dashboard").find("td:contains(Tournament:)").find("a").text(); // commented by jr
    var subject = mapname+' ';
    if( tourneyname ){
        subject += 'for '+tourneyname;
    }
    else {
        subject += type;
    }
    subject = subject.substring(0,60);  //max length for subjects
   
    //make fake post form to add users to pm form   
    var form='<form id="PMTEAMFORM" method="post" target="_blank" action="/forum/ucp.php?i=pm&mode=compose">';
   
    for( var i = 0; i < teamplayers.length - 1; i++){
        form += '<input type="hidden" name="address_list[u]['+ teamplayers[i] +']" value="to"/>';
    }
   
    // required to get form not to give error..
    form += '<input type="hidden" name="add_to['+teamplayers[teamplayers.length-1] +']" value="Add"/>';
   
    form += '<input type="hidden" name="subject" value="'+subject+'"/>'
    form += '<input type="hidden" name="message" value="[Game]'+gamenumber+'[/Game]"/>'
    form += '<input type="submit" name="" value="" style="display:none;" />'
    form += '</form>';
   

    $('<button>PM Teammates</button>').insertAfter("#players").click(function(){
        var evt = document.createEvent("HTMLEvents");
   evt.initEvent("submit", true, true);
        // tries to submit the form in two different ways for chrome and FF
        $(form).insertAfter("#chat-form").submit().get(0).dispatchEvent(evt);
    });
   
}


i tested it and checked the code. it should work without problems. tho i removed your name from the code. your name is in the changelog. i dont want to bloat the code with names when i hope more of the community will help updating these scripts then it will be like 20 names inside the code. so your name is on the changelog for this version.

also i will give you 600 CC credits. as thanks. maybe its a little much for this small update. but i still want to point out that im rewarding this kind of things and hopefully encouraging other ppl to create scripts and update them.
Image
Cornering men with the phrase "sexual harassment" is an abuse of power.
User avatar
Lieutenant dgz345
Head Tech
Head Tech
 
Posts: 1081
Joined: Thu Oct 07, 2010 10:53 am
Medals: 50
Standard Achievement (3) Doubles Achievement (2) Triples Achievement (2) Quadruples Achievement (2) Terminator Achievement (1)
Assassin Achievement (1) Manual Troops Achievement (2) Freestyle Achievement (2) Polymorphic Achievement (1) Nuclear Spoils Achievement (1)
Fog of War Achievement (3) Trench Warfare Achievement (2) Speed Achievement (1) Teammate Achievement (1) Random Map Achievement (2)
Cross-Map Achievement (3) Beta Map Achievement (1) Ratings Achievement (4) Tournament Achievement (2) General Achievement (4)
Clan Achievement (5) Challenge Achievement (2) General Contribution (3)

Previous

Return to Third-Party Tools & Enhancements

Who is online

Users browsing this forum: No registered users

Login