Main Page: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
No edit summary
(Replace us.o link with a page for script hosting links.)
(32 intermediate revisions by 21 users not shown)
Line 1: Line 1:
__NOTOC__
'''GreaseSpot''' is community documentation for [[user script]]ing with [[Greasemonkey]].
'''GreaseSpot''' is community documentation for [[user script]]ing with [[Greasemonkey]]. Please [[GreaseSpot:Editor portal|contribute]].
 
== Getting Started ==
Before writing a script or posting to the [[mailing list]] for help, '''every''' script writer should read Mark Pilgrim's [http://www.oreillynet.com/lpt/a/6257 Avoid Common Pitfalls in Greasemonkey].


<!-- I'm not fond of the mess of HTML here, but it's especially helpful to have an attractive and easy-to-use main page. -->
<table style='min-width: 35em; max-width: 60em; margin: 1em auto; float: none;' class='infobox'>
<tr>
<th style='width: 50%; text-align: center;'>For All Users</th>
<th style='width: 50%; text-align: center;'>For Script Authors</th>
</tr>
<tr>
<td>
* [[Greasemonkey Manual]]
* [[Greasemonkey Manual]]
* [[FAQ]]
* [[Troubleshooting (Users)]]
* [[User Script Hosting]]
</td>
<td>
* [[Avoid Common Pitfalls in Greasemonkey]]
* [[Greasemonkey Manual:API|API reference]]
* [[Troubleshooting (Script Authors)]]
* [[Security]]
* [[Tutorials]]
* [[Tutorials]]
* [[Mailing list]]
* [[:Category:Coding Tips]]
* [[:Category:Scripting context]]
</td>
</tr>
</table>


== Scripting References ==
Last resort?
Try reading the [[Getting Help]] page.
<br><br><br><br><br><br><br><br><br><br><br><br>


* [[API reference]]
<!--
* [[Metadata block]]
arantius: I want the main page to be clean and clear, a portal to documents that themselves may lead to content.  These links are noisy and not terribly helpful.  I plan on reworking their content to be easier to navigate through and adding them back.
* [[:Category:Scripting context|Scripting context]]
** [[Sandbox]]
** [[Global object]]
** [[XPCNativeWrapper]]
** [[Scriptable content]]
** [[DOMContentLoaded]]
* [[Security]]
** [[unsafeWindow]]


== Authoring Tips ==
* [[Controlling userscripts in sub windows]]
* [[Useful Tools for Script Writers]]
* [[Troubleshooting]]
* [[0.7.20080121.0+ compatibility]]: Working around errors introduced by changes in Greasemonkey 0.7.20080121.0
* [[Code snippets]]: useful staple functions.
* [[Coding tips]]: things you might not have thought of.
* [[HTML injection tips]]: how to add your html anywhere, dodging page CSS invading yours
* [[:Category:Site-specific tips|Site-specific tips]]
** [[:Category:Ajax site tips|Ajax site tips]]
* [[Security tips]]
* [[Security tips]]
* [[Etiquette]]
* [[Cross-browser userscripting]]
* [[Cross-browser userscripting]]
 
-->
== Extension Development ==
 
* [http://greasemonkey.devjavu.com/projects/greasemonkey/wiki/ContributeToGreasemonkey Contributing to Greasemonkey ]
 
== Also ==
 
* [[FAQ]]
* [[Links]]
----
 
----
 
----
// ==UserScript==
// @name          FB_PIC
// @namespace      fb
// @description    Shows the full sized profile picture when you mouseover profile links
// @include        http://*.facebook.com/*
// ==/UserScript==
 
 
// *********************
//
// Utility Functions
//
// *********************
function wait(c,f){ if (c()) f(); else window.setTimeout(function (){wait(c,f)},300,false);}
function $(e) { return document.getElementById(e); }
String.prototype.getID = function(){ return parseInt(this.substr(this.indexOf('id=')+3)); }
String.prototype.getSearchProfileID = function() { return parseInt(this.substr(this.indexOf('(')+1)); }
String.prototype.include = function(pattern){ return this.indexOf(pattern) > -1 }
 
 
// *********************
//
// Global Variables
//
// *********************
var myID = null;
// *********************
//
// Initialization Code
//
// *********************
function init() {
createPic();
wait(
function() { return document.getElementsByTagName('li')[0] && !isNaN(document.getElementsByTagName('li')[0].childNodes[0].href.getID()) },
function() { myID = document.getElementsByTagName('li')[0].childNodes[0].href.getID(); }
);
var a = document.getElementsByTagName('a');
for (var i = 0; i < a.length; i++) {
if (a[i].href.getID() == myID) continue;
if (a[i].href.include('profile.php?id=') || a[i].href.include('s.php?k=')) {
bindEvents(a[i]);
} else if (a[i].getAttribute("onclick")) {
if (a[i].getAttribute("onclick").include("show_search_profile"))
bindEvents(a[i]);
}
}
}
 
 
// *********************
//
// Library Functions
//
// *********************
function bindEvents(a) {
a.addEventListener('mouseover', find, true);
a.addEventListener('mousemove', function(ev) {
wait(
function() { return ($('FB_PIC').clientHeight > 0 && $('FB_PIC').clientWidth > 0 && ev.clientX > 0); },
function() { show(ev.clientX, ev.clientY, $('FB_PIC').clientHeight, $('FB_PIC').clientWidth); }
);
}, true);
a.addEventListener('mouseout', function(){$('FB_PIC').innerHTML = '';$('FB_PIC').style.visibility='hidden';}, true);
}
 
function find(ev) {
if (ev.target.tagName == 'IMG') {
var id = ev.target.parentNode.href.getID() || ev.target.parentNode.getAttribute('onclick').getSearchProfileID();
var pic = ev.target.src;
} else if (ev.target.tagName == 'A') {
if (ev.target.href.include('#')) return;
var id = ev.target.href.getID() || ev.target.getAttribute('onclick').getSearchProfileID();
var imgs = document.getElementsByTagName('img');
for (var i = 0; i < imgs.length; i++) {
if (imgs[i].src.include(id) && !imgs[i].src.include('photos')) {
var pic = imgs[i].src;
break;
}
}
}
if (pic) {
pic = pic.substr(0,pic.indexOf(id)-1)+'n'+pic.substr(pic.indexOf(id));
$('FB_PIC').innerHTML = '<img src="'+pic+'"/>';
}
}
 
function show(x, y, h, w) {
$('FB_PIC').style.top = window.scrollY+y-(.5*h)+'px';
while (parseInt($('FB_PIC').style.top,10)+h >= window.innerHeight+window.scrollY)
$('FB_PIC').style.top = parseInt($('FB_PIC').style.top,10)-30+'px';
 
while (parseInt($('FB_PIC').style.top,10) <= window.scrollY)
$('FB_PIC').style.top = 30+parseInt($('FB_PIC').style.top,10)+'px';
if (window.innerWidth-15 <= window.scrollX+x+w+25)
$('FB_PIC').style.left = x-w-25+window.scrollX+'px';
else
$('FB_PIC').style.left = (window.scrollX+x+25)+'px';
 
$('FB_PIC').style.visibility = 'visible';
}
 
function createPic() {
var pic = document.createElement('div');
pic.setAttribute('id', 'FB_PIC');
pic.style.position = 'absolute';
pic.style.zIndex = 10000;
pic.style.visibility = 'hidden';
document.body.appendChild(pic);
}
 
wait(function() { return document.body },init());
 
<div><!--[if IE]><style type="text/css">#bl-title { background: #000 !important; }</style><![endif]--><div id="bm-bg"><div id="bl-title" onclick="window.open('http://www.adaptiveblue.com','_newTab');"></div><div id="bl-closebutton" class="bluepane-closebutton-off"><input id="bl-closebutton-button" type="button" style="visibility:hidden;"></input></div><div id="powered-by-link" onclick="window.open('http://www.adaptiveblue.com','_newTab');"></div><iframe name="content" id="bl-iframe" class="bluepane-iframe" width="482" height="371" scrolling="no" frameborder="0"></iframe></div>
<div><iframe name="content" style="margin:0px;padding:0px;background-color:transparent;" id="bl-hover-iframe" height="62" width="260" scrolling="no" frameborder="0"></iframe><div style="text-align:left;"><div id="bl-caret"></div></div>

Revision as of 14:18, 3 March 2014