Skip to content

Commit

Permalink
Version 0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
welbert committed Dec 3, 2016
1 parent c223919 commit ec335b6
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 13 deletions.
1 change: 1 addition & 0 deletions data/lib/toast.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 41 additions & 1 deletion data/scripts/context-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function parserCommand(node, data) {
default:
result = null;
}

toast("Code copied to clipboard!");
return result;
}

Expand All @@ -53,6 +53,9 @@ function getGDUrl() {
}

function getGDClick(node) {
//Simulação da ação
node.click();

return `click('` + getCssSelector(node) + `');`;
}

Expand Down Expand Up @@ -82,6 +85,10 @@ function getGDFillIn(node) {
var cssSelector = getCssSelector(node);
var message = customPrompt('Fill in with: ');
if(!message) message = "";

//Simulação da ação
node.value = message;

return `fillIn('` + cssSelector + `','` + message.toString() + `');`;
}

Expand All @@ -93,22 +100,41 @@ function getGDSubmit(node) {
if(tmpNode.localName === "form")
node = tmpNode;

//Simulação da ação
var cssSelector = getCssSelector(node);
node.submit();

return `submit('` + cssSelector + `');`
}

function getGDWait(node) {
var cursor = document.body.style.cursor;
document.body.style.cursor = 'progress';

var cssSelector = getCssSelector(node);
var timeOut = customPrompt("Time limit for wait of element.[ms] (Default: 5000)");
if(isNullOrEmpty(timeOut))
timeOut = '5000';

setTimeout(function() {
document.body.style.cursor = cursor;
}, 1000);

return `wait('` + cssSelector + `',` + timeOut + `);`;
}

function getGDSleep() {
var cursor = document.body.style.cursor;
document.body.style.cursor = 'progress';

var time = customPrompt("Time to sleep.[ms]");
if(isNullOrEmpty(time))
time = '1000';

setTimeout(function() {
document.body.style.cursor = cursor;
}, 1000);

return `sleep('` + time.toString().trim() + `');`;
}

Expand Down Expand Up @@ -138,3 +164,17 @@ function isNullOrEmpty(variable) {
function setReturn(message) {
self.postMessage(message);
}

function toast(message) {
var toast = new iqwerty.toast.Toast(message, {
settings: {
duration: 2000
},
style: {
main: {
width: '25%'
}
}

});
}
31 changes: 20 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var MenuItemCssSelector = contextMenu.Item({
context: contextMenu.SelectorContext("*"),
onMessage: onContextGetCssSelector,
accesskey: "C",
contentScriptFile: [data.url("lib/css-logic.js"), data.url("scripts/context-script.js")]
contentScriptFile: [data.url("lib/toast.min.js"), data.url("lib/css-logic.js"), data.url("scripts/context-script.js")]
});

var menuLabelBefore = "> ";
Expand All @@ -62,58 +62,67 @@ var menuItemMain = contextMenu.Menu({
context: contextMenu.SelectorContext("*"),
onMessage: onContextGDFunction,
accesskey: "G",
contentScriptFile: [data.url("lib/css-logic.js"), data.url("scripts/context-script.js")],
contentScriptFile: [data.url("lib/toast.min.js"), data.url("lib/css-logic.js"), data.url("scripts/context-script.js")],
items: [
contextMenu.Item({
label: menuLabelBefore + "Get Url",
label: menuLabelBefore + "Get Url (U)",
accesskey: "U",
data: JSON.stringify({
command: "GetUrl"
})
}),
contextMenu.Item({
label: menuLabelBefore + "Click",
label: menuLabelBefore + "Click (L)",
accesskey: "L",
data: JSON.stringify({
command: "Click"
})
}),
contextMenu.Item({
label: menuLabelBefore + "TakeScreenshot",
label: menuLabelBefore + "TakeScreenshot (T)",
accesskey: "T",
data: JSON.stringify({
command: "TakeScreenshot"
})
}),
contextMenu.Item({
label: menuLabelBefore + "TakeScreenshotOf",
label: menuLabelBefore + "TakeScreenshotOf (S)",
accesskey: "S",
data: JSON.stringify({
command: "TakeScreenshotOf"
})
}),
contextMenu.Item({
label: menuLabelBefore + "FillIn",
label: menuLabelBefore + "FillIn (F)",
accesskey: "F",
data: JSON.stringify({
command: "FillIn"
})
}),
contextMenu.Item({
label: menuLabelBefore + "Submit",
label: menuLabelBefore + "Submit (B)",
accesskey: "U",
data: JSON.stringify({
command: "Submit"
})
}),
contextMenu.Item({
label: menuLabelBefore + "Wait",
label: menuLabelBefore + "Wait (W)",
accesskey: "W",
data: JSON.stringify({
command: "Wait"
})
}),
contextMenu.Item({
label: menuLabelBefore + "Sleep",
label: menuLabelBefore + "Sleep (E)",
accesskey: "E",
data: JSON.stringify({
command: "Sleep"
})
}),
contextMenu.Item({
label: menuLabelBefore + "Print",
label: menuLabelBefore + "Print (P)",
accesskey: "P",
data: JSON.stringify({
command: "Print"
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Guide-Automator",
"name": "guide-automator",
"version": "0.0.4",
"version": "0.0.5",
"description": "Help to build guide-automator(npm) blocks",
"main": "index.js",
"author": "Welbert Serra",
Expand Down

0 comments on commit ec335b6

Please sign in to comment.