Jump to content

Strange code displayed when replying to a mail problem and solution


Marky

Recommended Posts

Alright, this was discussed in another thread but as Mike suggested here's an own thread for this problem and a solution for people to find.

 

You may be sending some bit of code everytime you reply to a mail even though you might not be aware of it until someone asks/complains about it. You'll be able to see it in the outbox, outputted at the beginning of the mail before your message.

 

Basically, it looks like this:

 

(function main() {
if(!document.URL.match('www.mmatycoon.com/skillmaintenance.php')){
$('td[background*=\'images/bar\']')
.each(
function () {
var hypeValue = jQuery(this).attr("width").replace("%", "");
hypeValue = (hypeValue * 10).toFixed(0);
if(hypeValue < 280){
if(jQuery(this).next().html().search(/%.+/) == -1){ jQuery(this).next().append(" " + hypeValue); }
} else {
if(jQuery(this).html().search(/%.+/) == -1){ jQuery(this).append(hypeValue); }
}
}
);
jQuery("td[background*=images/img_redbar]")
.each(
function () {
var hypeValue = jQuery(this).attr("width").replace("%", "");
hypeValue = (hypeValue * 10).toFixed(0);
if(hypeValue < 280){
if(jQuery(this).next().html().search(/%.+/) == -1){ jQuery(this).next().append(" " + hypeValue); }
} else {
if(jQuery(this).html().search(/%.+/) == -1){ jQuery(this).append(hypeValue); }
}
}
);
$('table[background*=\'images/bar\']')
.each(
function () {
var hypeValue = jQuery(this).attr("width").replace("%", "");
hypeValue = (hypeValue * 10).toFixed(0);
jQuery(this).children().children().children().html(" " + hypeValue + "");
}
);
}
})();

 

 

It's because you're most likely using the MMATycoon Hype & Pop Displayer 0.0.1 script with Greasemonkey. Here's a copy paste of the solution:

 

 

I have been having this same problem for a while, that same code is added into the beginning of the message everytime when I reply to one.

 

Shutting down greasemonkey is not a good option so I dug into this a little bit. It seems the cause is a script called MMATycoon Hype & Pop Displayer 0.0.1. The script displays numerical values of the hype/pop etc. bars so it's really handy.

 

The initial settings in the script allows it to work on any page of the mmatycoon.com and somehow it functions on the mail page http://www.mmatycoon.com/mail.php too where it's not wanted and there's no bars to be displayed etc.

 

I'm not really good with these scripts so my solution may be rudimentary but I managed to edit it a bit to function properly and get rid of the problem. So ideally I wanted the script to be disabled on the mail page but the problem was the sub pages/the message pages which all have unique ID's. So I edited the script so that it's only allowed to be run in specified pages and not the whole site and this seemed to do the trick and my reply mails seem to look normal now :yes:

 

The beginning of THE ORIGINAL hypedisplayer.user.js looks like this:

 

// ==UserScript==
// @name MMATycoon Hype & Pop Displayer
// @description Displays the Values of Bars numerical
// @author Daniel Gebauer < danielgebauer@gmail.com >
// @version 0.0.1

// @match http://*.mmatycoon.com/*
// @include http://*.mmatycoon.com/*
// @copyright 2011 Daniel Gebauer
// ==/UserScript==

 

AND THE EDITED beginning of the hypedisplayer.user.js:

 

// ==UserScript==
// @name MMATycoon Hype & Pop Displayer
// @description Displays the Values of Bars numerical
// @author Daniel Gebauer < danielgebauer@gmail.com >
// @version 0.0.1

// @include http://*.mmatycoon.com/fighter*
// @include http://*.mmatycoon.com/manager*
// @include http://*.mmatycoon.com/org*
// @include http://*.mmatycoon.com/cloth*
// @include http://*.mmatycoon.com/nutr*
// @include http://*.mmatycoon.com/scoutf*
// @include http://*.mmatycoon.com/event*
// @include http://*.mmatycoon.com/rankings*
// @copyright 2011 Daniel Gebauer
// ==/UserScript==

 

You can edit the script from Greasemonkey User Script Preferences which has edit button on the bottom or if you want to backup the file first and edit via text editor click the edit button and you'll see the file location on the top of the window. Hopefully Daniel Gebauer approves as the original script is his :)

 

 

 

Link to comment
Share on other sites

I just got this reply in my mail:

 



(function main() {
if(!document.URL.match('www.mmatycoon.com/skillmaintenance.php')){
$('td[background*=\'images/bar\']')
.each(
function () {
var hypeValue = jQuery(this).attr("width").replace("%", "");
hypeValue = (hypeValue * 10).toFixed(0);
if(hypeValue < 280){
if(jQuery(this).next().html().search(/%.+/) == -1){ jQuery(this).next().append(" " + hypeValue); }
} else {
if(jQuery(this).html().search(/%.+/) == -1){ jQuery(this).append(hypeValue); }
}
}
);
jQuery("td[background*=images/img_redbar]")
.each(
function () {
var hypeValue = jQuery(this).attr("width").replace("%", "");
hypeValue = (hypeValue * 10).toFixed(0);
if(hypeValue < 280){
if(jQuery(this).next().html().search(/%.+/) == -1){ jQuery(this).next().append(" " + hypeValue); }
} else {
if(jQuery(this).html().search(/%.+/) == -1){ jQuery(this).append(hypeValue); }
}
}
);
$('table[background*=\'images/bar\']')
.each(
function () {
var hypeValue = jQuery(this).attr("width").replace("%", "");
hypeValue = (hypeValue * 10).toFixed(0);
jQuery(this).children().children().children().html(" " + hypeValue + "");
}
);
}
})();
Sorry, but its not me me who call a shots around there :/ and lately we had to kick a few ppl coz co-owners decided that is too crowd...not much I can do about it :(

Link to comment
Share on other sites

just got this one as a reply from a contract offer:

 

 

Contract Offered

  Fighter : Jerson Pelaez
  Org : Steel Penn - NY
  Org Base : New York
  Weight : 145 lbs
  Fights : 3
  Signing Bonus : 3000
  Base Pay : 3000
  Win Bonus : 3000
  Expires : 01 Apr 2014
  Inactivity Clause : 31
  Exclusive : Yes

Link to comment
Share on other sites

  • 1 year later...

I had this going on forever but never bothered to do anything about it until today. So, for the sake of having a semi-permanent answer posted for this, you have to change those "include" tags to "match" tags. The full script, for anyone running it who just wants to copy and paste the whole thing, is this:

// ==UserScript==
// @name               MMATycoon Hype & Pop Displayer
// @description        Displays the Values of Bars numerical
// @author             Daniel Gebauer < danielgebauer@gmail.com >
// @version            0.0.1
// @match         http://*.mmatycoon.com/fighter*
// @match        http://*.mmatycoon.com/manager*
// @match        http://*.mmatycoon.com/org*
// @match        http://*.mmatycoon.com/cloth*
// @match        http://*.mmatycoon.com/nutr*
// @match        http://*.mmatycoon.com/scoutf*
// @match        http://*.mmatycoon.com/event*
// @match        http://*.mmatycoon.com/rankings*
// @match        http://*.mmatycoon.com/rankings*
// @copyright          2011 Daniel Gebauer
// ==/UserScript==

function addJQuery(callback) {
  var script = document.createElement("script");
  script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js");
  script.addEventListener('load', function() {
    var script = document.createElement("script");
    script.textContent = "(" + callback.toString() + ")();";
    document.body.appendChild(script);
  }, false);
  document.body.appendChild(script);
}

// the guts of this userscript
function main() {
	if(!document.URL.match('www.mmatycoon.com/skillmaintenance.php')){
		$('td[background*=\'images/bar\']')
			.each(
				function () {
					var hypeValue = jQuery(this).attr("width").replace("%", "");
					hypeValue = (hypeValue * 10).toFixed(0);
					if(hypeValue < 280){
						if(jQuery(this).next().html().search(/%.+/) == -1){ jQuery(this).next().append(" " + hypeValue); } 
					} else {
						if(jQuery(this).html().search(/%.+/) == -1){ jQuery(this).append(hypeValue); } 
					}
				}
			);
		jQuery("td[background*='images/img_redbar']")
			.each(
				function () {
					var hypeValue = jQuery(this).attr("width").replace("%", "");
					hypeValue = (hypeValue * 10).toFixed(0);
					if(hypeValue < 280){
						if(jQuery(this).next().html().search(/%.+/) == -1){ jQuery(this).next().append(" " + hypeValue); } 
					} else {
						if(jQuery(this).html().search(/%.+/) == -1){ jQuery(this).append(hypeValue); }
					}
				}
			);
			$('table[background*=\'images/bar\']')
			.each(
				function () {
					var hypeValue = jQuery(this).attr("width").replace("%", "");
					hypeValue = (hypeValue * 10).toFixed(0);
						jQuery(this).children().children().children().html("<font color='white'> " + hypeValue + "</font>");
				}
			);
	}
}

// load jQuery and execute the main function
if(document.URL.match('mmatycoon.com')){
	addJQuery(main);
}


edit: Added alliance pages to the script.
Edited by reggie
Link to comment
Share on other sites

×
×
  • Create New...