Moderator: Tech Team
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);
});
}
RobbieDub wrote:I'm using it on Firefox but I turn it on and off through grease monkey when I need it because it screws up the snapshot function
Silly Knig-it wrote:I was doing what RobbieDub was doing and was okay with that. Since the Firefox upgrade none of the greasemonkey extensions work for me.
Firefox Quantum 57.0.1
Mac OS High Sierra 10.13.1
Update: I played around and learned to install Tampermonkey and this script works for me now.
RobbieDub wrote:Silly Knig-it wrote:I was doing what RobbieDub was doing and was okay with that. Since the Firefox upgrade none of the greasemonkey extensions work for me.
Firefox Quantum 57.0.1
Mac OS High Sierra 10.13.1
Update: I played around and learned to install Tampermonkey and this script works for me now.
are you using tampermonkey on firefox?
I switched to Chrome and use tampermoney now and it works well.
Silly Knig-it wrote:RobbieDub wrote:Silly Knig-it wrote:I was doing what RobbieDub was doing and was okay with that. Since the Firefox upgrade none of the greasemonkey extensions work for me.
Firefox Quantum 57.0.1
Mac OS High Sierra 10.13.1
Update: I played around and learned to install Tampermonkey and this script works for me now.
are you using tampermonkey on firefox?
I switched to Chrome and use tampermoney now and it works well.
Yes, tampermonkey on firefox
Major bob wrote:318 users on line and no one can tell me how to install an attack simulation add-on?
RobbieDub wrote:Hey I'm having problems with the panel interface auto snapshots and it seems to be connected to the Team PM script. When the script is active the snapshot is from the start of the turn when I'm really at the end of the turn. When I turn that particular script off the snapshots work fine. Here is some info from my bug report.
Operating System: OS x 10.9.4
Browser: Firefox 31
Scripts/third party programs used: assault odds 2.0.3, chatglove 1.8.1, Team PM 1.0.0
The auto snapshot taken with the panel interface at the end of the turn shows a picture of the map at the start of the turn in all of my active games. I have to leave the game and return to it to get an accurate snapshot of the map after my turn.
dgz345 wrote:
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.
agentcom wrote:dgz345 wrote:
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.
This is great to hear!
And perfect timing, too. It sounds like I should finally ditch firefox, which I was using only for CC and only because of the add-ons that were available. Reading through the last page or so of this thread, it sounds like Chrome is now the more reliable way to keep these add-ons running.
RobbieDub wrote:Hmm my dashboard looks the same but I added Map Rank later. Maybe delete maprank and see if assault odds works then.
I also keep assault odds in its own window on the game page if that makes a difference for some reason.
Users browsing this forum: No registered users