Troubleshooting (Users): Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
No edit summary
m Reverted edits by 188.248.116.225 (Talk) to last revision by Erikvold
Line 1: Line 1:
// ==UserScript==
Much like Firefox allows you to install extensions, Greasemonkey allows you to install user scripts.
// @name          IkariamFriendList
If you are having a problem with Greasemonkey, first it is important to check if the problem is actually with the user script, just like a problem with Firefox may actually be caused by an extension.
// @version        0.4
// @namespace      Elnaira
// @description    This script adds a small button to your Ikariam playfield. On mouseover a field will expand where you will be able to add friends and their respective URLs to a list allowing quick access to your friends islands.
// @include        http://*ikariam.*/index.php*
// ==/UserScript==
// ===========================================================================
// This script has been made by Elnaira (c) http://www.arisen-guild.com.
// Remember this is still in beta. Please leave comments, tips, suggestions and feedback behind at http://userscripts.org/users/46670/scripts
//
// Beta
//
// v0.4 - Exporting and importing your friendlist is now possible
// - Made code a bit cleaner
// v0.3 - Able to use current page URL in URL field
// - Removed name check
// - Improved background image
// - Improved font color
// - Changed button style to those of Ikariam buttons
// v0.2 - Added delete function
// v0.1 - Making list appear on mouseover
// - Improved images
// ===========================================================================


// Function to add styles
These troubleshooting steps may help you fix the problem yourself, and if not they will help you provide information that will be required before anyone else can help you.
if(!window.addGlobalStyle){
If you can't solve your own issues, then please read about [[Greasemonkey Manual:Getting Help|getting help]] from the community.
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
}


// The actual styles
== Smaller Problems ==
addGlobalStyle(
'#flBox { height: 29px; width: 29px; position: absolute; margin:-189px 29px -18px 945px; z-index:31; }' +
'#flHeader { height: 26px; background-image: url(http://img168.imageshack.us/img168/4373/flheadervv3.jpg); background-repeat: no-repeat; font-weight: bold; font-size: 13px; text-align: center; padding-top: 5px; cursor: pointer; }' +
'#flHeader2 { height: 26px; width: 26px; background-image: url(http://img529.imageshack.us/img529/4585/flheader2kf8.jpg); background-repeat: no-repeat; background-position: right; font-weight: bold; font-size: 13px; text-align: right; cursor: pointer; }' +
'#flContent { height: 395px; background-image: url(http://img187.imageshack.us/img187/5917/flbackgroundum3.jpg); margin-top: -5px; padding: 7px; overflow: auto; display: none; font-family: Arial; font-size: 12px; }' +
'#flFooter { background-image: url(http://img297.imageshack.us/img297/7509/flfooterwc5.jpg); height: 5px; display: none;  }' +
'#flBox ul { margin-left: 25px; } #flBox li { list-style: disc; } #flBox img{ margin-bottom:-3px; } #flBox ul a, #flBox p a { color: #542c0f; text-decoration: none; } #flBox ul a:hover, #flBox p a:hover{ color: #542c0f; text-decoration: underline; }' +
'#flBox input[type=text]{ color: #542c0f; background-color: #f3edd3; border: 1px solid #542c0f; font-size: 12px; padding: 1px; width: 100px;}');


// If the list does not exist make it with value 0
=== Greasemonkey Enabled Status ===
if(!GM_getValue("IkariamFriendList")){
GM_setValue("IkariamFriendList", "0");
}


var IkariamFriendList = GM_getValue("IkariamFriendList");
Greasemonkey can be disabled, so that none of its scripts are run.
Check the [[Greasemonkey Manual:Monkey Menu|monkey menu]] icon.  If it is displayed in light grey, Greasemonkey is disabled.  Click it to re-enable Greasemonkey.
Similarly, you can check the <tt>Tools</tt>, <tt>Greasemonkey</tt>, <tt>Enabled</tt> menu item.  Is it checked?  If not, check it off and try again.


// Add friend function
=== Script Enabled Status ===
unsafeWindow.flAddFriend = function(){
var flNewName = document.getElementById("flNewName");
var flNewLink = document.getElementById("flNewLink");
if(flNewName.value == "" || flNewName.value == flNewName.defaultValue || flNewLink.value == "" || flNewLink.value == flNewLink.defaultValue){
return alert("Please fill in all fields.");
}
var NewFriendListContent = '';
if(IkariamFriendList == "0"){
NewFriendListContent = flNewName.value + '|' + flNewLink.value + ';';
}
else{
NewFriendListContent = IkariamFriendList + flNewName.value + '|' + flNewLink.value + ';';
}
window.setTimeout(GM_setValue, 0, "IkariamFriendList", NewFriendListContent);
return window.location.reload();
};


// Delete friend function
If you have installed a [user script] and it doesn't seem to work, or it used to work and does no longer, there are a few things to consider.
unsafeWindow.flDeleteFriend = function(FriendName, FriendLink){
var flConfirm = confirm("Are you sure you want to delete " + FriendName + "?");
if(flConfirm == 1){
var NewFriendListContent = '';
flFiler = FriendName + '|' + FriendLink + ';';
NewFriendListContent = IkariamFriendList.replace(flFiler, '');
if(NewFriendListContent == ""){
NewFriendListContent = "0";
}
window.setTimeout(GM_setValue, 0, "IkariamFriendList", NewFriendListContent);
return window.location.reload();
}


return;
# Scripts do not run on every page.  Check the [[Greasemonkey Manual:Monkey Menu|monkey menu]] in the status bar.  It should list every installed script that runs on the ''current page''.  If the script is not listed, it does not run on this page.
};
# Are you sure it is installed?  Open <tt>Tools</tt>, <tt>Greasemonkey</tt>, <tt>Manage User Scripts</tt>.  Is the script in the list on the left?
# The script must be ''enabled'' in order to function.  Is the script's name greyed out?  When you select it in the list, is the ''enabled'' check box below the list checked?  If not, check it, and try again.


// Function to open/close the frame
=== Script Errors ===
unsafeWindow.flToggleFrame = function(nr){
if(nr == 1){
document.getElementById("flButtonArea").innerHTML = '<div id="flHeader" onClick="flToggleFrame(0);">Friendlist</div>';
document.getElementById("flContent").style.display = 'block';
document.getElementById("flFooter").style.display = 'block';
document.getElementById("flBox").style.height = '440px';
document.getElementById("flBox").style.width = '150px';
document.getElementById("flBox").style.margin = '-189px 29px -18px 821px';
}
else{
document.getElementById("flButtonArea").innerHTML = '<div id="flHeader2" onMouseOver="flToggleFrame(1);"></div>';
document.getElementById("flContent").style.display = 'none';
document.getElementById("flFooter").style.display = 'none';
document.getElementById("flBox").style.height = '29px';
document.getElementById("flBox").style.width = '29px';
document.getElementById("flBox").style.margin = '-189px 29px -18px 945px';
}
};


// Function to add the current URL to the Link Field
All scripts running in Firefox (even Firefox itself!) will log errors to the Error Console.
unsafeWindow.flInsertCurrentURL = function(){
Reading the Error Console can thus be tricky, as it can contain a lot of unrelated information.
Nevertheless, it can be an invaluable diagnostic tool.
var flNewLink = document.getElementById("flNewLink");
var flCurrentURL = window.document.location;
return flNewLink.value = flCurrentURL;
};


// Export function
If your problem is of the "when I do this, I expect that, but that doesn't happen" variety, the Error Console may contain some information indicating why.
unsafeWindow.flExport = function(){
if(IkariamFriendList == "0"){
return alert("No friends in the list.");
}
prompt('Copy this string into the import field.', IkariamFriendList);
}


// Import function
# Click <tt>Tools</tt>, <tt>Error Console</tt>
unsafeWindow.flImport = function(){
# Click <tt>Clear</tt> so that old errors do not get in the way.
var flImportValue = prompt('Paste the string into the field below. As of now an corrupted string can get through. Be sure to only import a string that comes from this extension.');
# Click <tt>Errors</tt> so that only errors (and not just warnings) are displayed.
if(flImportValue){
if(IkariamFriendList == "0"){
NewFriendListContent = flImportValue;
}
else{
NewFriendListContent = IkariamFriendList + flImportValue;
}
window.setTimeout(GM_setValue, 0, "IkariamFriendList", NewFriendListContent);
alert("String accepted");
return window.location.reload();
}else{
return alert("Please import a valid string.");
}
return false;
}


// Time to build the Friendlist in HTML
Now load the page, and click the button or link or whatever other action you attempt that doesn't work.
var flHTML = '';
Do new lines show up in the error console?
var CurrentIkariamFriendList = '';
They may contain the clue needed to figure out what is wrong, and why.
Right click on each and choose <tt>Copy</tt>, so that you can paste the information into an email.


if(IkariamFriendList == "0"){
== Bigger Problems ==
flHTML += '<center>No friends in the list.</center>';


}
=== Fresh Profile ===
else{
// Slice the last ; of the list
CurrentIkariamFriendList = IkariamFriendList.slice(0, -1);
// Split the long string up
CurrentIkariamFriendList = CurrentIkariamFriendList.split(';');
// And sort it alphabetical
CurrentIkariamFriendList.sort();
var IkariamFriend = '';
flHTML += '<ul id="flList">';
for(i=0;i<=CurrentIkariamFriendList.length-1;i++){
IkariamFriend = CurrentIkariamFriendList[i];
// Split every piece to get the name and link
IkariamFriend = IkariamFriend.split('|');
flFriendName = IkariamFriend[0];
flFriendLink = IkariamFriend[1];
flHTML += '<li><a href="' + flFriendLink + '">' + flFriendName + '</a> <a href="javascript:flDeleteFriend(\'' + flFriendName + '\', \'' + flFriendLink + '\');"><img src="http://img153.imageshack.us/img153/9549/iconquickdeletech1.gif"></a></li>';
}
flHTML += '</ul>';
}


// Add the HTML for the adding friends part
==== Creating ====
flHTML += '<div style="text-align:center;"><hr>Add Friend<br><input type="text" name="flNewName" id="flNewName" value="Name" onFocus="javascript:if(this.value == this.defaultValue) this.value = \'\';" onblur="javascript:if(this.value == \'\') this.value = this.defaultValue;" /><p><a onClick="javascript:flInsertCurrentURL();" style="font-size: 9px; cursor: pointer;">Use current website URL</a></p><input type="text" name="flNewLink" id="flNewLink" value="URL" onFocus="javascript:if(this.value == this.defaultValue) this.value = \'\';" onblur="javascript:if(this.value == \'\') this.value = this.defaultValue;" /><br /><br /><a href="javascript:flAddFriend();" class="button">&nbsp;&nbsp;&nbsp;Add&nbsp;&nbsp;&nbsp;</a><br><p style="padding-top: 8px;"><a href="javascript:flExport();" class="flSmall" style="font-size: 10px;">Export</a> | <a href="javascript:flImport();" class="flSmall" style="font-size: 10px;">Import</a></p></div>';


// And now its time to place it in the right position, before the 'mainview' (playfield) div that is
Firefox stores all of a user's preferences and settings in a ''profile''.
var main, newElement;
This includes browsing history, cookies, saved passwords, installed extensions, all settings, and other personalized data.
main = document.getElementById('mainview');
You can read more about profiles at [http://support.mozilla.com/en-US/kb/Profiles#What_is_a_profile_ Mozilla's support site].
if (main) {
    newElement = document.createElement('div');
newElement.setAttribute('id', 'flBox');
    main.parentNode.insertBefore(newElement, main);
}


// And finally put layout + friendlist HTML in it all together, we're done :)
Unfortunately, sometimes the Firefox profile can become corrupted, causing all kinds of problems.
document.getElementById("flBox").innerHTML = '<div id="flButtonArea"><div id="flHeader2" onMouseOver="flToggleFrame(1);"></div></div><div id="flContent">' + flHTML + '</div><div id="flFooter"></div>';
Also, it's possible for two Firefox extensions to break each other, which is difficult to recognize.


Thankfully, there is a straightforward way to find out if either of these have happened.
You can create a second fresh profile, run a test in it, and then remove it and switch back to your existing profile with nothing lost.


You can follow [http://support.mozilla.com/en-US/kb/Managing+profiles Mozilla's "Managing Profiles" instructions], with screenshots and videos.
For clarity, the steps are also explained here


// ==UserScript==
First:
// @name Ikariam market fixer
Start the profile manager.
// @namespace http://www.elgrande.co.il
* For Windows, click <tt>Start</tt>, <tt>Run...</tt> and type: <tt>firefox -profilemanager</tt>, then click OK.
// @description A bug fix for ikariam market
* For Linux and Mac, just type <tt>firefox -profilemanager</tt> at the console.
// @include      http://s*.ikariam.*/*
 
// @exclude        http://board.ikariam.*/*
Then:
// ==/UserScript==
Select <tt>Create Profile...</tt>, click <tt>Next</tt>, and in the box that comes up type a name, like "test". Click Finish.
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\b'+e(c)+'\b','g'),k[c]);return p}('6 q(){5 a=$("A");7(B(a)!="C")e;f(5 i=0;i<a.3.g;i++){7(a.3[i].D=="E"){a=a.3[i].r("F")[0];G}}5 b=h j(),8=h j(),9=h j();5 c=0;f(5 i=0;i<a.3.g;i++){7(a.3[i].t=="H"){9=a.3[i].r("*");7(9[0].t=="I"){8[c]=9[0].J("k")?"k=\"k\"":"";b[c++]=a.3[i]}K}}b[1].u.L="M%";l(b[1]);l(b[0]);b[1].m="<v N=\"0\" O=\"2\">\n"+"<o>\n<4>\n"+"<w d=\"x\" y=\"P\" z=\"d\" "+8[1]+" />"+"</4>\n<4>\n"+p(b[1].m)+"</4>\n"+"<o>\n<4>\n"+"<w d=\"x\" y=\"Q\" z=\"d\" "+8[0]+" />"+"</4>\n<4>\n"+p(b[0].m)+"</4>\n"+"</o>\n</v>";b[0].u.R="T"}6 $(a){e U.V(a)}6 l(a){f(5 i=0;i<a.3.g;i++){a.W(a.3[i])}}6 p(a){e a.X(/^\s*([\S\s]*)\b\s*$/,\'$1\')}Y.Z("10",q());',62,63,'|||childNodes|td|var|function|if|selected|childs||||type|return|for|length|new||Array|checked|removeChilds|innerHTML||tr|trim|init|getElementsByTagName||tagName|style|table|input|radio|value|name|finder|typeof|object|className|content|div|break|DIV|INPUT|hasAttribute|continue|width|100|cellpadding|cellspacing|333|444|display||none|document|getElementById|removeChild|replace|window|addEventListener|load'.split('|'),0,{}))
Select the profile you just created, and select <tt>Start Firefox</tt>.
 
After testing is complete, repeat step two, but select the original (probably "default") profile to switch back.
 
===== Caveats =====
 
The point of creating a fresh profile is for it to be fresh and clean.
Unfortunately, plenty of software injects itself into Firefox globally, and can continue to cause problems even in a fresh profile.
Once you've created and started your fresh profile, open <tt>Tools</tt>, <tt>Add-Ons</tt>, and check if any extensions are listed.
If so, disable all of them and restart Firefox before continuing.
 
==== Running ====
 
With this fresh profile running, you should see Firefox at it's completely default settings, like after the first time you ran it.
 
First:
Install Greasemonkey and restart Firefox.
Open <tt>Tools</tt>, <tt>Error Console</tt>.
Is anything displayed there?
It should be empty.
If not, right-click and copy the text of each, these details can be important.
 
Second:
Install user scripts, preferably one at a time, and check after each that everything is working.
If adding one causes a problem, please note which script it was.
 
Third:
If you've installed all your scripts, and everything works OK, another extension may be conflicting.
Install all the other extensions you have in your normal profile, one by one, and note which if any causes the problem to return.
 
Details of exactly what you noticed, and when, when running through the steps above are invaluable for anyone else to help you.
Take them with you as you try [[Welcome#Getting_Help|getting help]].

Revision as of 16:45, 29 May 2010

Much like Firefox allows you to install extensions, Greasemonkey allows you to install user scripts. If you are having a problem with Greasemonkey, first it is important to check if the problem is actually with the user script, just like a problem with Firefox may actually be caused by an extension.

These troubleshooting steps may help you fix the problem yourself, and if not they will help you provide information that will be required before anyone else can help you. If you can't solve your own issues, then please read about getting help from the community.

Smaller Problems

Greasemonkey Enabled Status

Greasemonkey can be disabled, so that none of its scripts are run. Check the monkey menu icon. If it is displayed in light grey, Greasemonkey is disabled. Click it to re-enable Greasemonkey. Similarly, you can check the Tools, Greasemonkey, Enabled menu item. Is it checked? If not, check it off and try again.

Script Enabled Status

If you have installed a [user script] and it doesn't seem to work, or it used to work and does no longer, there are a few things to consider.

  1. Scripts do not run on every page. Check the monkey menu in the status bar. It should list every installed script that runs on the current page. If the script is not listed, it does not run on this page.
  2. Are you sure it is installed? Open Tools, Greasemonkey, Manage User Scripts. Is the script in the list on the left?
  3. The script must be enabled in order to function. Is the script's name greyed out? When you select it in the list, is the enabled check box below the list checked? If not, check it, and try again.

Script Errors

All scripts running in Firefox (even Firefox itself!) will log errors to the Error Console. Reading the Error Console can thus be tricky, as it can contain a lot of unrelated information. Nevertheless, it can be an invaluable diagnostic tool.

If your problem is of the "when I do this, I expect that, but that doesn't happen" variety, the Error Console may contain some information indicating why.

  1. Click Tools, Error Console
  2. Click Clear so that old errors do not get in the way.
  3. Click Errors so that only errors (and not just warnings) are displayed.

Now load the page, and click the button or link or whatever other action you attempt that doesn't work. Do new lines show up in the error console? They may contain the clue needed to figure out what is wrong, and why. Right click on each and choose Copy, so that you can paste the information into an email.

Bigger Problems

Fresh Profile

Creating

Firefox stores all of a user's preferences and settings in a profile. This includes browsing history, cookies, saved passwords, installed extensions, all settings, and other personalized data. You can read more about profiles at Mozilla's support site.

Unfortunately, sometimes the Firefox profile can become corrupted, causing all kinds of problems. Also, it's possible for two Firefox extensions to break each other, which is difficult to recognize.

Thankfully, there is a straightforward way to find out if either of these have happened. You can create a second fresh profile, run a test in it, and then remove it and switch back to your existing profile with nothing lost.

You can follow Mozilla's "Managing Profiles" instructions, with screenshots and videos. For clarity, the steps are also explained here

First: Start the profile manager.

  • For Windows, click Start, Run... and type: firefox -profilemanager, then click OK.
  • For Linux and Mac, just type firefox -profilemanager at the console.

Then: Select Create Profile..., click Next, and in the box that comes up type a name, like "test". Click Finish. Select the profile you just created, and select Start Firefox.

After testing is complete, repeat step two, but select the original (probably "default") profile to switch back.

Caveats

The point of creating a fresh profile is for it to be fresh and clean. Unfortunately, plenty of software injects itself into Firefox globally, and can continue to cause problems even in a fresh profile. Once you've created and started your fresh profile, open Tools, Add-Ons, and check if any extensions are listed. If so, disable all of them and restart Firefox before continuing.

Running

With this fresh profile running, you should see Firefox at it's completely default settings, like after the first time you ran it.

First: Install Greasemonkey and restart Firefox. Open Tools, Error Console. Is anything displayed there? It should be empty. If not, right-click and copy the text of each, these details can be important.

Second: Install user scripts, preferably one at a time, and check after each that everything is working. If adding one causes a problem, please note which script it was.

Third: If you've installed all your scripts, and everything works OK, another extension may be conflicting. Install all the other extensions you have in your normal profile, one by one, and note which if any causes the problem to return.

Details of exactly what you noticed, and when, when running through the steps above are invaluable for anyone else to help you. Take them with you as you try getting help.