Skip to content

Commit

Permalink
Merge pull request #266 from jdi-testing/issue-262
Browse files Browse the repository at this point in the history
Issue-262: Taking a screenshot and saving a file at the same time
  • Loading branch information
Bryant-24 authored Jul 22, 2021
2 parents 26737af + 48ff8e5 commit e384173
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "JDN",
"description": "",
"devtools_page": "index.html",
"version": "3.0.29",
"version": "3.0.30",
"permissions": [
"activeTab",
"tabs",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jdi-react-extension",
"version": "3.0.29",
"version": "3.0.30",
"description": "jdi react extension",
"scripts": {
"start": "npm run webpack",
Expand Down
7 changes: 4 additions & 3 deletions src/js/blocks/autoFind/autoFindProvider/AutoFindProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
requestXpathes,
} from "./pageDataHandlers";
import { reportProblemPopup } from "./contentScripts/reportProblemPopup/reportProblemPopup";
import { saveJson } from './contentScripts/saveJson';
import { JDIclasses, getJdiClassName } from "./generationClassesMap";
import { connector, sendMessage } from "./connector";

Expand Down Expand Up @@ -102,8 +101,10 @@ const AutoFindProvider = inject("mainModel")(
};

const reportProblem = (predictedElements) => {
connector.attachContentScript(reportProblemPopup)
.then(saveJson(JSON.stringify(predictedElements)));
chrome.storage.sync.set(
{ predictedElements },
connector.attachContentScript(reportProblemPopup)
);
};

const updateElements = ([predicted, page]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@ export const reportProblemPopup = () => {
}

function saveImage(frame) {
var imageLink = document.createElement('a');
let imageLink = document.createElement('a');
imageLink.href = frame;
imageLink.download = 'screenshot.jpg';
imageLink.click();
}

saveJson = (content) => {
let a = document.createElement("a");
let file = new Blob([content], {type: 'text/plain'});
a.href = URL.createObjectURL(file);
a.download = 'json.txt';
a.click();
}

const backgroundModal = document.createElement('div');
backgroundModal.classList.add('jdn-report-problem-popup__background');

Expand All @@ -30,9 +38,9 @@ export const reportProblemPopup = () => {

const descriptionText = document.createElement('p');
descriptionText.innerHTML = `
To find the real problem, we need to get the TXT-file (json.txt, it was just downloaded) and a screenshot of the site with the identified elements on it (screenshot.jpg). <br> <br>
To find the real problem, we need to get the txt-file (json.txt) and a screenshot of the site with the identified elements on it (screenshot.jpg). <br> <br>
To take a screenshot, you need: <br>
To take a screenshot and get the json file, you need: <br>
- press the OK button in this window <br>
- select the 'Window' tab in the newly appeared window <br>
- select the Chrome browser <br>
Expand Down Expand Up @@ -69,8 +77,11 @@ export const reportProblemPopup = () => {
const frame = canvas.toDataURL("image/png");
captureStream.getTracks().forEach(track => track.stop());

saveImage(frame);
mailTo();
chrome.storage.sync.get(["predictedElements"], ({predictedElements}) => {
saveJson(predictedElements);
saveImage(frame);
mailTo();
});
}
};

Expand Down

This file was deleted.

0 comments on commit e384173

Please sign in to comment.