Skip to content

Commit

Permalink
v1.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Kholid060 authored Mar 15, 2022
2 parents 751ef88 + a3b20cf commit 75becb8
Show file tree
Hide file tree
Showing 12 changed files with 389 additions and 49 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "automa",
"version": "1.4.1",
"version": "1.4.4",
"description": "An extension for automating your browser by connecting blocks",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -36,6 +36,7 @@
"@vuex-orm/core": "^0.36.4",
"compare-versions": "^4.1.2",
"crypto-js": "^4.1.1",
"css-selector-generator": "^3.6.0",
"dayjs": "^1.10.7",
"defu": "^5.0.1",
"drawflow": "^0.0.51",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ async function interactionHandler(block, { refData }) {
frameId: this.activeTab.frameId || 0,
});

if (block.data.saveData || block.data.getValue) {
if (
(block.data.saveData && block.name !== 'forms') ||
block.data.getValue
) {
const currentColumnType =
this.columns[block.data.dataColumn]?.type || 'any';
const insertDataToColumn = (value) => {
Expand Down
6 changes: 5 additions & 1 deletion src/components/newtab/logs/LogsDataViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ const dataStr = computed(() => {
});
function exportData(type) {
dataExporter(props.log.data, { name: state.fileName, type }, true);
dataExporter(
props.log.data?.table || props.log.data,
{ name: state.fileName, type },
true
);
}
</script>
54 changes: 40 additions & 14 deletions src/content/element-selector/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
</template>
<script setup>
import { reactive, ref, watch, inject, nextTick } from 'vue';
import { finder } from '@medv/finder';
import { getCssSelector } from 'css-selector-generator';
import { debounce } from '@/utils/helper';
import AppBlocks from './AppBlocks.vue';
import AppSelector from './AppSelector.vue';
Expand Down Expand Up @@ -193,7 +193,12 @@ const cardRect = reactive({
/* eslint-disable no-use-before-define */
const getElementSelector = (element) =>
state.selectorType === 'css' ? finder(element) : generateXPath(element);
state.selectorType === 'css'
? getCssSelector(element, {
includeTag: true,
blacklist: ['[focused]', /focus/],
})
: generateXPath(element);
function generateXPath(element) {
if (!element) return null;
Expand Down Expand Up @@ -299,27 +304,48 @@ function handleMouseMove({ clientX, clientY, target }) {
Object.assign(hoverElementRect, getElementRect(target));
}
function handleClick(event) {
const { target, path } = event;
const { target, path, ctrlKey, shiftKey } = event;
if (target === rootElement || state.hide || state.isExecuting) return;
event.preventDefault();
event.stopPropagation();
event.preventDefault();
const attributes = Array.from(target.attributes).map(({ name, value }) => ({
name,
value,
}));
state.selectedElements = [
{
...getElementRect(target),
attributes,
element: target,
highlight: false,
},
];
state.elSelector = getElementSelector(target);
let targetElement = target;
const targetElementDetail = {
...getElementRect(target),
attributes,
element: target,
highlight: false,
};
if ((state.selectorType === 'css' && ctrlKey) || shiftKey) {
let elementIndex = -1;
const elements = state.selectedElements.map(({ element }, index) => {
if (element === targetElement) {
elementIndex = index;
}
return element;
});
if (elementIndex === -1) {
targetElement = [...elements, target];
state.selectedElements.push(targetElementDetail);
} else {
targetElement = elements.splice(elementIndex, 1);
state.selectedElements.splice(elementIndex, 1);
}
} else {
state.selectedElements = [targetElementDetail];
}
state.elSelector = getElementSelector(targetElement);
selectedElement.index = 0;
selectedElement.path = path;
Expand Down
2 changes: 1 addition & 1 deletion src/content/element-selector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function elementSelectorInstance() {

const automaStyle = document.createElement('style');
automaStyle.classList.add('automa-element-selector');
automaStyle.innerHTML = `.automa-element-selector { pointer-events: none } \n [automa-isDragging] { user-select: none }`;
automaStyle.innerHTML = `.automa-element-selector { pointer-events: none; direction: ltr } \n [automa-isDragging] { user-select: none }`;

initElementSelector(rootElement);

Expand Down
10 changes: 5 additions & 5 deletions src/content/services/record-workflow.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { finder } from '@medv/finder';
import { getCssSelector } from 'css-selector-generator';
import browser from 'webextension-polyfill';
import { debounce } from '@/utils/helper';

Expand Down Expand Up @@ -27,7 +27,7 @@ function changeListener({ target }) {
if (execludeInput) return;

let block = null;
const selector = finder(target);
const selector = getCssSelector(target);
const isSelectEl = target.tagName === 'SELECT';
const elementName = target.ariaLabel || target.name;

Expand Down Expand Up @@ -94,7 +94,7 @@ function keyEventListener({

if (isTextField) return;

const selector = finder(target);
const selector = getCssSelector(target);

addBlock({
id: 'trigger-event',
Expand Down Expand Up @@ -125,7 +125,7 @@ function clickListener(event) {

if (isTextField) return;

const selector = finder(target);
const selector = getCssSelector(target);

if (target.tagName === 'A') {
if (event.ctrlKey || event.metaKey) return;
Expand Down Expand Up @@ -167,7 +167,7 @@ function clickListener(event) {
const scrollListener = debounce(({ target }) => {
const isDocument = target === document;
const element = isDocument ? document.documentElement : target;
const selector = isDocument ? 'html' : finder(target);
const selector = isDocument ? 'html' : getCssSelector(target);

addBlock((recording) => {
const lastFlow = recording.flows[recording.flows.length - 1];
Expand Down
Loading

0 comments on commit 75becb8

Please sign in to comment.