Troubleshooting (Users): Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
(Undo revision 5181 by 24.12.75.94 (Talk))
No edit summary
Line 1: Line 1:
Much like Firefox allows you to install extensions, Greasemonkey allows you to install user scripts.
// ==UserScript==
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.
// @name          IkariamFriendList
// @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
// ===========================================================================


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.
// Function to add styles
If you can't solve your own issues, then please read about [[Greasemonkey Manual:Getting Help|getting help]] from the community.
if(!window.addGlobalStyle){
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);
}
}


== Smaller Problems ==
// The actual styles
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;}');


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


Greasemonkey can be disabled, so that none of its scripts are run.
var IkariamFriendList = GM_getValue("IkariamFriendList");
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.


=== Script Enabled Status ===
// Add friend function
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();
};


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.
// Delete friend function
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();
}


# 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.
return;
# 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.


=== Script Errors ===
// Function to open/close the frame
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';
}
};


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


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.
// Export function
unsafeWindow.flExport = function(){
if(IkariamFriendList == "0"){
return alert("No friends in the list.");
}
prompt('Copy this string into the import field.', IkariamFriendList);
}


# Click <tt>Tools</tt>, <tt>Error Console</tt>
// Import function
# Click <tt>Clear</tt> so that old errors do not get in the way.
unsafeWindow.flImport = function(){
# Click <tt>Errors</tt> so that only errors (and not just warnings) are displayed.
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.');
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;
}


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


== Bigger Problems ==
if(IkariamFriendList == "0"){
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>';
}


==== Creating ====
// Add the HTML for the adding friends part
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>';


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


Unfortunately, sometimes the Firefox profile can become corrupted, causing all kinds of problems.
// And finally put layout + friendlist HTML in it all together, we're done :)
Also, it's possible for two Firefox extensions to break each other, which is difficult to recognize.
document.getElementById("flBox").innerHTML = '<div id="flButtonArea"><div id="flHeader2" onMouseOver="flToggleFrame(1);"></div></div><div id="flContent">' + flHTML + '</div><div id="flFooter"></div>';
 
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
 
First:
Start the profile manager.
* For Windows, click <tt>Start</tt>, <tt>Run...</tt> and type: <tt>firefox -profilemanager</tt>, then click OK.
* For Linux and Mac, just type <tt>firefox -profilemanager</tt> at the console.
 
Then:
Select <tt>Create Profile...</tt>, click <tt>Next</tt>, and in the box that comes up type a name, like "test". Click Finish.
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 10:43, 29 May 2010

// ==UserScript== // @name IkariamFriendList // @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 if(!window.addGlobalStyle){ 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 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 if(!GM_getValue("IkariamFriendList")){ GM_setValue("IkariamFriendList", "0"); }

var IkariamFriendList = GM_getValue("IkariamFriendList");

// Add friend function 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 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; };

// Function to open/close the frame unsafeWindow.flToggleFrame = function(nr){

if(nr == 1){

document.getElementById("flButtonArea").innerHTML = '

Friendlist

';

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 = '

';

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 unsafeWindow.flInsertCurrentURL = function(){

var flNewLink = document.getElementById("flNewLink"); var flCurrentURL = window.document.location;

return flNewLink.value = flCurrentURL;

};

// Export function unsafeWindow.flExport = function(){

if(IkariamFriendList == "0"){ return alert("No friends in the list."); }

prompt('Copy this string into the import field.', IkariamFriendList);

}

// Import function unsafeWindow.flImport = function(){ 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.');

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 var flHTML = ; var CurrentIkariamFriendList = ;

if(IkariamFriendList == "0"){

flHTML += '

No friends in the list.

';

} 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 += '

    '; 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 += '
  • <a href="' + flFriendLink + '">' + flFriendName + '</a> <a href="javascript:flDeleteFriend(\ + flFriendName + '\', \ + flFriendLink + '\');"><img src="http://img153.imageshack.us/img153/9549/iconquickdeletech1.gif"></a>
  • '; } flHTML += '

';

}

// Add the HTML for the adding friends part

flHTML += '


Add Friend
<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;" />

<a onClick="javascript:flInsertCurrentURL();" style="font-size: 9px; cursor: pointer;">Use current website URL</a>

<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;" />

<a href="javascript:flAddFriend();" class="button">   Add   </a>

<a href="javascript:flExport();" class="flSmall" style="font-size: 10px;">Export</a> | <a href="javascript:flImport();" class="flSmall" style="font-size: 10px;">Import</a>

';

// And now its time to place it in the right position, before the 'mainview' (playfield) div that is var main, newElement; main = document.getElementById('mainview'); 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 :)

document.getElementById("flBox").innerHTML = '

' + flHTML + '

';