Created
May 10, 2009 22:14
-
-
Save jbgutierrez/109770 to your computer and use it in GitHub Desktop.
Exportador de tareas de Somethings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name export_somethings_data.js | |
// @namespace jbgutierrez.info | |
// @description Export "Somethings" data | |
// @include http://thn.gs/ | |
// ==/UserScript== | |
// Add jQuery | |
var GM_JQ = document.createElement('script'); | |
GM_JQ.src = 'http://jquery.com/src/jquery-latest.js'; | |
GM_JQ.type = 'text/javascript'; | |
document.getElementsByTagName('head')[0].appendChild(GM_JQ); | |
// Check if jQuery's loaded | |
function GM_wait() { | |
if(typeof unsafeWindow.jQuery == 'undefined') { window.setTimeout(GM_wait,100); } | |
else { $ = unsafeWindow.jQuery; letsJQuery(); } | |
} | |
GM_wait(); | |
// All your GM code must be inside this function | |
function letsJQuery() { | |
$('#button-sign-out').after('<div id="exportar" class="button">Exportar</div>'); | |
$('#exportar').click(function() { | |
$.getJSON('/', {action: "get", folder: "active"}, | |
function(json){ | |
var result = ''; | |
var append = function(str, blank){ | |
result = result + str + '\n'; | |
if (blank) | |
result = result + '\n'; | |
}; | |
var textilize = function(title, issues){ | |
if (issues.length > 0) | |
{ | |
append('h3. ' + title, true); | |
for each(issue in issues) | |
{ | |
var text = issue.title; | |
if (issue.done == 0) | |
{ | |
if (issue.tags.indexOf('!') != -1 | issue.tags.indexOf('$') != -1) | |
text = '_' + text + '_'; | |
if (issue.tags.indexOf('?') != -1 | issue.tags.indexOf('=') != -1) | |
text = '*' + text + '*'; | |
} | |
else | |
{ | |
text = '-' + text + '-'; | |
} | |
append('# ' + text); | |
} | |
append(' '); | |
} | |
}; | |
var areas = json.issues.filter(function(issue){ return issue.link == null; }); | |
for each(area in areas) | |
{ | |
var issues = json.issues.filter(function(issue){ return issue.link == area.id; }); | |
var week = issues.filter(function(issue){ return issue.focus == "today" & issue.folder == "active" }); | |
var next = issues.filter(function(issue){ return issue.focus == "normal" & issue.folder == "active" }); | |
append('h2. ' + area.title, true); | |
textilize('Esta semana', week); | |
textilize('Siguiente', next); | |
} | |
unsafeWindow.copyToClipboard(result); | |
}); | |
}); | |
} | |
unsafeWindow.copyToClipboard = function(text) { | |
this.netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); | |
const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper); | |
gClipboardHelper.copyString(text); | |
} | |
//signed.applets.codebase_principal_support;true | |
// { | |
// id: 43597, | |
// title: "Corregir install.sh para que haga links simbólicos", | |
// notes: "", | |
// done: 0, | |
// type: "task", | |
// folder: "active", | |
// focus: "today", | |
// tags: [!", ":equipo"], | |
// due: null, | |
// link: 43621, | |
// weight: 9 | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment