I\'m trying to create a Greasemonkey script that adds a draggable div to every web page. For some reason, the div isn\'t displaying at all. What might be the reason for this?
I've created a working userscript that adds a draggable div to every page. Here is the source code:
// ==UserScript==
// @name Div on top
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description enter something useful
// @match https://*/*
// @match http://*/*
// @match *.com*
// @match *.net*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js
// @require http://code.jquery.com/ui/1.9.2/jquery-ui.js
// @copyright 2012+, You
// ==/UserScript==
jQuery(function($){
var _highest = 0;
$("div").each(function() {
var _current = parseInt($(this).css("zIndex"), 10);
if(_current > _highest) {
_highest = _current + 1;
}
});
$('body').append('
');
$( "#draggableDiv" ).draggable();
$('#draggableDiv').mouseup(function() {
//alert('Set the x and y values using GM_getValue.');
var divOffset = $("#draggableDiv").offset();
var left = divOffset.left;
var top = divOffset.top;
GM_setValue("left", left);
GM_setValue("top", top);
//alert("Set left to " + left + " and top to " + top);
});
});