I have trouble adapting this command... can anyone help me?
In Ubiquity 0.1.x I used the bugmenot command a lot... but now it
doesn't work in 0.5. I'm trying to adapt it to the new parser, but
sadly it still does not work. I have no idea what I'm doing wrong, it
must be something to do with how the arguments are used in
functions...
Can anyone help me with this code??? Oh, and the create search command
doesn't seem to work, because the commands it creates don't work (must
be related to the new parser?)
/*
This file has been modified from Onur Yalazi's original distribution
by Brandon Goldsworthy and Alejandro Carrazzoni. This version only
works with
Ubiquity 0.5 or newer. For Ubiquity 0.1.x go to
http://www.yalazi.org/ubiquity/comman...
Changes:
Added a preview. The preview shows all of bugmenot's results,
though execute will still only insert the highest rated one.
Use current window location as default url for both preview and
execute
Add error callback to jQuery call to bugmenot's page.
If not in editable field, opens bugmenot in new tab
Adapted to work in Parser 2.
Onur's original attribution info is left in-tact below.
You can get his original file there.
*/
CmdUtils.CreateCommand({
names: ["bugmenot", "find logins"]
homepage: "http://www.yalazi.org/ubiquity",
author: { name: "Onur YALAZI", email: "yal...@gen3.com.tr"},
license: "MPL",
description: "modified by Brandon Goldsworthy and Alejandro
Carrazzoni. Get password for current page or entry from bugmenot.com",
help: "If you're in an editable text area, inserts
<username:password> double",
_decodeIt: function(data,key) {
var b64 =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var o11 = "";var o21 = ""; var o31 = "";
var h11 = "";var h21 = ""; var h31 = "";var h41 = "";
var bits1 = ""; var i1 = 0; var enc1 = "";
do {
h11 = b64.indexOf(data.charAt(i1++));
h21 = b64.indexOf(data.charAt(i1++));
h31 = b64.indexOf(data.charAt(i1++));
h41 = b64.indexOf(data.charAt(i1++));
bits1 = h11 << 18 | h21 << 12 | h31 << 6 | h41;
o11 = bits1 >> 16 & 255;
o21 = bits1 >> 8 & 255;
o31 = bits1 & 255;
if (h31 == 64) {
enc1 += String.fromCharCode(o11);
} else if (h41 == 64) {
enc1 += String.fromCharCode(o11, o21);
} else {
enc1 += String.fromCharCode(o11, o21, o31);
}
} while (i1 < data.length);
strInput = enc1;
strOutput = "";
intOffset = (key + 112) / 12;
for (i1 = 4; i1 < strInput.length; i1++) {
thisLetter = strInput.charAt(i1);
thisCharCode = strInput.charCodeAt(i1);
newCharCode = thisCharCode - intOffset;
strOutput += String.fromCharCode(newCharCode);
}
return strOutput;
},
_inField: function(){
//gleaned from CmdUtils.setSelection
return context.focusedWindow.document.designMode == "on" ||
(context.focusedElement &&
context.focusedElement.selectionStart >= 0);
},
_getPassword: function(urlAddress, parent, pblock) {
var baseUrl = "http://www.bugmenot.com/view/" + args.object.text;
if (!pblock && !this._inField()){
Utils.openUrlInBrowser(baseUrl);
}else{
jQuery.ajax({
url:baseUrl,
error:function(){
if (pblock){
pblock.innerHTML += "Passwords not found.
";
}else{
displayMessage("Passwords not found.");
CmdUtils.setSelection("Passwords not found.");
}
},
success:function( passwords ) {
key = parseInt(passwords.match(/key.=.([0-9]*)/)[1]);
var result = "";
arrayToWork = passwords.split("
I’m frustrated
doesn't work in 0.5. I'm trying to adapt it to the new parser, but
sadly it still does not work. I have no idea what I'm doing wrong, it
must be something to do with how the arguments are used in
functions...
Can anyone help me with this code??? Oh, and the create search command
doesn't seem to work, because the commands it creates don't work (must
be related to the new parser?)
/*
This file has been modified from Onur Yalazi's original distribution
by Brandon Goldsworthy and Alejandro Carrazzoni. This version only
works with
Ubiquity 0.5 or newer. For Ubiquity 0.1.x go to
http://www.yalazi.org/ubiquity/comman...
Changes:
Added a preview. The preview shows all of bugmenot's results,
though execute will still only insert the highest rated one.
Use current window location as default url for both preview and
execute
Add error callback to jQuery call to bugmenot's page.
If not in editable field, opens bugmenot in new tab
Adapted to work in Parser 2.
Onur's original attribution info is left in-tact below.
You can get his original file there.
*/
CmdUtils.CreateCommand({
names: ["bugmenot", "find logins"]
homepage: "http://www.yalazi.org/ubiquity",
author: { name: "Onur YALAZI", email: "yal...@gen3.com.tr"},
license: "MPL",
description: "modified by Brandon Goldsworthy and Alejandro
Carrazzoni. Get password for current page or entry from bugmenot.com",
help: "If you're in an editable text area, inserts
<username:password> double",
_decodeIt: function(data,key) {
var b64 =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var o11 = "";var o21 = ""; var o31 = "";
var h11 = "";var h21 = ""; var h31 = "";var h41 = "";
var bits1 = ""; var i1 = 0; var enc1 = "";
do {
h11 = b64.indexOf(data.charAt(i1++));
h21 = b64.indexOf(data.charAt(i1++));
h31 = b64.indexOf(data.charAt(i1++));
h41 = b64.indexOf(data.charAt(i1++));
bits1 = h11 << 18 | h21 << 12 | h31 << 6 | h41;
o11 = bits1 >> 16 & 255;
o21 = bits1 >> 8 & 255;
o31 = bits1 & 255;
if (h31 == 64) {
enc1 += String.fromCharCode(o11);
} else if (h41 == 64) {
enc1 += String.fromCharCode(o11, o21);
} else {
enc1 += String.fromCharCode(o11, o21, o31);
}
} while (i1 < data.length);
strInput = enc1;
strOutput = "";
intOffset = (key + 112) / 12;
for (i1 = 4; i1 < strInput.length; i1++) {
thisLetter = strInput.charAt(i1);
thisCharCode = strInput.charCodeAt(i1);
newCharCode = thisCharCode - intOffset;
strOutput += String.fromCharCode(newCharCode);
}
return strOutput;
},
_inField: function(){
//gleaned from CmdUtils.setSelection
return context.focusedWindow.document.designMode == "on" ||
(context.focusedElement &&
context.focusedElement.selectionStart >= 0);
},
_getPassword: function(urlAddress, parent, pblock) {
var baseUrl = "http://www.bugmenot.com/view/" + args.object.text;
if (!pblock && !this._inField()){
Utils.openUrlInBrowser(baseUrl);
}else{
jQuery.ajax({
url:baseUrl,
error:function(){
if (pblock){
pblock.innerHTML += "Passwords not found.
";
}else{
displayMessage("Passwords not found.");
CmdUtils.setSelection("Passwords not found.");
}
},
success:function( passwords ) {
key = parseInt(passwords.match(/key.=.([0-9]*)/)[1]);
var result = "";
arrayToWork = passwords.split("
1) {
o_password = "";
o_username = "";
o_rate = 0;
for (i=0;i<arraytowork> o_rate) {
o_password = password;
o_username = username;
o_rate = rate;
}
}
}
if (o_rate > 0) {
result = o_username + ':' + o_password;
} else {
result = 'Passwords not found.';
if (pblock){
pblock.innerHTML += "Passwords not found.
";
}
}
} else {
result = 'Passwords not found.';
if (pblock){
pblock.innerHTML += "Passwords not found.
";
}
}
if (!pblock){
displayMessage(result);
CmdUtils.setSelection(result);
}
}
});
}
},
arguments: [{role: "object", nountype: noun_arb_text, label:
"url"}],
preview: function( pblock, args ) {
pblock.innerHTML = "";
if (args.object.text.length < 1){
args.object.text = String
(Application.activeWindow.activeTab.document.location);
}
pblock.innerHTML = "Passwords for: " + args.object.text + "
";
this._getPassword(args, this, pblock);
},
execute: function( args ) {
if (args.object.text.length < 1){
args.object.text = String
(Application.activeWindow.activeTab.document.location);
}
this._getPassword(args, this, false);
}
Oh, and I tried posting this in the Google group, but nobody answered me, so I'm trying here...</username:password>
o_password = "";
o_username = "";
o_rate = 0;
for (i=0;i<arraytowork> o_rate) {
o_password = password;
o_username = username;
o_rate = rate;
}
}
}
if (o_rate > 0) {
result = o_username + ':' + o_password;
} else {
result = 'Passwords not found.';
if (pblock){
pblock.innerHTML += "Passwords not found.
";
}
}
} else {
result = 'Passwords not found.';
if (pblock){
pblock.innerHTML += "Passwords not found.
";
}
}
if (!pblock){
displayMessage(result);
CmdUtils.setSelection(result);
}
}
});
}
},
arguments: [{role: "object", nountype: noun_arb_text, label:
"url"}],
preview: function( pblock, args ) {
pblock.innerHTML = "";
if (args.object.text.length < 1){
args.object.text = String
(Application.activeWindow.activeTab.document.location);
}
pblock.innerHTML = "Passwords for: " + args.object.text + "
";
this._getPassword(args, this, pblock);
},
execute: function( args ) {
if (args.object.text.length < 1){
args.object.text = String
(Application.activeWindow.activeTab.document.location);
}
this._getPassword(args, this, false);
}
Oh, and I tried posting this in the Google group, but nobody answered me, so I'm trying here...</username:password>
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
-
Inappropriate?The best place for all programming questions is the official Ubiquity Google group.
I’m hopeful
The company says
this answers the question
Loading Profile...




EMPLOYEE