I'm trying out to build my first firefox addon, to solve a problem that I have at work :
I'm trying to automate a part of my daily work on a website I'm using (not developping). I have to crawl several lists on the website, dig an item in the list, to check some values, and do it again and again ...
Im used to developping in Powershell and python, not with a web browser. I have limited rights on the machine I'm working on. The only solution I can easily deploy is a firefox addon on a firefox portable. I'd like to use this to catch the json answers of the website (all of them), parse the answers for some values, and automate some kind of popup "Hey, This item in the list is between 90 and 100 !"
The network console allows me to see the jsons, and I know how to parse it well (I'm actually using a powershell script for this, but I can't connect it to the network console AFAIK)
I found a way to trigger the work at the right time :
function logJson(requestDetails) {
console.log("Chargement : " + requestDetails.url);
}
browser.webRequest.onCompleted.addListener(
logRequests,
{urls: ["*://*.crappywebsi.te/*"],
types: ["xmlhttprequest"]
}
);
This code logs the url at the right moment (every time a json is loaded)
Is it possible to catch the json on the fly, to parse it, look for specific values in a path, calculate something, and popup the result ?
Or just save the json somewhere ?
How ?
I dont want to add a button on the webpage. I want a signal that some values are right. a popup or console log is an good solution for me.
Thanks for your help !
Related
When a get request is sent to: 'http://localhost:4000/features'
There is a response with JSON Data which has HTML inside it.
I need the contents of the field name and description to be saved as PDF
Sample:
[{"_id":"5ad4951d0ba1c37c65818bc7","name":"Find your work faster","description":"<p>With an improved <strong>quick search</strong>, searching through all your issues and projects will be nothing else but a breeze. Whether you know the full issue key, part of the issue name, or just have a distant memory of a project from a year ago, start typing the words, and we’ll do the rest for you. The quick search instantly shows the most relevant results, and refreshes them whenever you change your search term.</p>\n\n<p><img alt=\"\" src=\"https://confluence.atlassian.com/jirasoftware/files/945521251/945528523/1/1518181922686/quicksearch.png\" style=\"height:400px; width:800px\" /></p>\n\n<p>If you’ve already found what you were looking for, just treat quick search as a handy work diary. Click anywhere in the box to see the issues and projects you’ve been working on recently, and have the most important work always at your fingertips.</p>\n\n<p>Learn more</p>\n","__v":0},{"_id":"5ad5ddddcd054b2b5b20143c","name":"Project sidebar","description":"<p>The project sidebar that we previewed in JIRA 6.4 is here to stay. We built this new navigation experience to make it easier for you to find what you need in your projects. It's even better, if you are using JIRA Agile: your backlog, sprints, and reports are now just a click away. If you've used the sidebar with JIRA Agile before, you'll notice that cross-project boards, which include multiple projects, now have a project sidebar as well — albeit a simpler version.</p>\n","__v":0}]
Can this be done in nodeJS?
Conversion isn't the right word but generation is. According to the generalized response in json response you can write logic for generation of pdf from it in node-js server.
PDFKit and PDFmake are two good libraries for this purpose.
I've used pdfmake and is very good.
See doc here: https://pdfmake.github.io/docs/
Use html-pdf to generated PDF from html, Where it works on top of phantom
var pdf = require('html-pdf');
pdf.create(file[0].description).toFile('./' + file[0].description + '.pdf', function (err, res) {
console.log(res.filename);
});
Note : Sample code snippet above to handle first object in your array
this is one heck of a confusing question to ask so here it goes. Firstly, I'm not asking you to write me any code I just need help going in the right direction for what I'm trying to achieve here. Basically the task is this, I want to scan a select area of a web page's source code for changes and if something does change, I want to report it somewhere (like a console or something). However, I do not want just a notification of change, I also want what the change is/was. I've been looking into things like jsoup but I am still struggling to even find out what this is called.
Any pointers would be insanely appreciated. Thanks, Optimistic.
Here are some steps assuming this is from a node.js project:
Get the URL for the specific script file you're looking for a change in.
Using the request() module, fetch that URL.
Break the data up into lines (probably using .split()).
Find the specific line you are looking for either by counting line numbers of by searching for some representative text in that line.
Using some sort of search in that line (perhaps a regex), find the current value of the exact item in that line you are looking for.
Save the current value.
Then, at some future time, repeat this whole process and compare what you find to the previous value.
If this is being done from a browser instead of node.js, then use an Ajax call to retrieve the file. If the file is on another domain from your web page and that domain does not permit cross-origin requests, then you cannot solve this problem in an automated fashion from a browser in your own web page.
Here is how I would do it with Jsoup:
Document doc = Jsoup.connect(url).get();
String scriptCssQuery = "script"; // Tune this CSS query to find THE script you need.
Element script = doc.select(scriptCssQuery).first();
if (script != null) {
String scriptLines = script.html();
// Store the changing line somewhere and compare it to its previous value...
}
I'm currently familiarizing myself with Google BigQuery by working through the examples at https://cloud.google.com/bigquery/web-ui-quickstart. Doing a query over the pubic datasets runs fine.
I run into problems when uploading custom data into a new table through the WebUI. I create a new dataset and table, and upload the csv file provided with the example case. As in the example I input the schema and submit the file. Now the upload window stays on top and turns grey as if it's working. Nothing seems to happen afterwards though. When clicking away the upload window after a long wait, the table seems to be created in the tree on the left. However, when clicking on the table an error is shown:
"Unable to find table: ndwtest-984:csvtest.csvdata"
This seems like a trivial action, however I cannot seems to get it to work. I've tried varies different files, uploaded the file to Google Cloud Storage first and played around with the advanced options the last two days, but keep getting the same error.
Help would be much appreciated.
Some steps to help you:
billing must be enabled
you need to choose to upload one single TXT file from the example eg: yob2013.txt and not the zip file
make sure the schema is entered as text: name:string,gender:string,count:integer
on the last screen of the wizard you don't need to change the default CSV option parameters (for demo purposes works as it is)
I just tried the example, and it does work for me. In case you still have errors, than you can check your Job History menu in the Web UI, direct link would be, warning you need to put your Id in the link.
https://bigquery.cloud.google.com/jobs/YOUR_ANONYMOUS_PROJECT_ID_HERE?pli=1
I'm relatively new to batch commands and have been learning steadily. My problem is like this:
I've understood how to kill processes using batch commands using many different methods. However, I've been unable to figure out how to close a single tab in, preferably, chrome.
Any thoughts would be greatly appreciated!
Thanks!
So, I suppose I should state my exact problem.
I'm using notepad++ as my LaTeX compiler and sending the final pdf to chrome. The reason: I usually have ~20 tabs open related to the project I'm working on and it just makes my work much easier to split my screen between notepad++ and chrome.
My current batch file compiles the LaTeX code and sends the compiled document to chrome as a new tab. For obvious reasons, i don't want to close a tab each time I compile, so I thought that closing the current tab at the same time during compiling would solve my problem. But, I just can't find a way to get my batch file to only close the tab with my compiled pdf.
Thanks in advance!
check all running chrome instances/tabs with :
wmic process where "caption='chrome.exe'" get
and see processes properties.Probably the best indicator that you can rely on in this case is CreationDate (other properties are basically the same for all chrome instances) - it always comes in format YYYYMMDDHHmmss.ms and is easy for string comparison.But you'll have to know the time when it was started.
So I started using FlexPMD for static code analysis, and I want to add it to my team's build process. I have it running nicely from a shell script, and can view the results by clicking a button and uploading the desired (pmd.xml) output file in the Violations Viewer that comes with it (note there is also one online here: http://opensource.adobe.com/svn/opensource/flexpmd/bin/flex-pmd-violations-viewer.html).
But I'd like to view the results directly without having to take the extra step of clicking the upload button. I imagine there is some black magic URL parameter that works, but (if so) what is it? This site:
http://blogs.adobe.com/xagnetti/2009/09/load_pmd_results_directly_in_t.html
mentions referencing pmd.xml with a "report" URL param, like so:
http://opensource.adobe.com/svn/opensource/flexpmd/bin/flex-pmd-violations-viewer.html?report=path/to/my/pmd.xml
but it's not working for me. Has anyone encountered this problem and triumphed, by chance?
EDIT: More info...
The latter (opensource.adobe.com...) webpage has the following JavaScript:
function getReport()
{
if ( window.location.href.indexOf('=') == -1 )
{
return "";
}
var hashes = window.location.href.slice(window.location.href.indexOf('=') + 1);
return hashes;
}
var report = getReport();
which it passes into flashvars. Perhaps the format with which I'm passing pmd.xml is incorrect?
Okay, figured it out. The version of the violations viewer that ships with the open source FlexPMD does not allow for automatic viewing of reports (the HTML wrapper doesn't pass in the report filepath, and the SWF doesn't take it in). The solution that worked for me was to download the files from the online violations viewer here:
http://opensource.adobe.com/svn/opensource/flexpmd/bin/flex-pmd-violations-viewer.html?report=path/to/my/pmd.xml
by using your browser to just save the webpage, and then curl to save the SWF file (directly trying to save from the browser will not work - appears to redirect to a null address) to like so:
curl -O http://opensource.adobe.com/svn/opensource/flexpmd/bin/flex-pmd-violations-viewer-1.1.swf
and place in the same directory as the violations viewer html file you downloaded. Then you can read your reports automatically! Here is an example (absolute filepath on Mac):
file:///path/to/your/violations-viewer/ViolationsViewer.html?report=/Users/joverton/some/project/path/bin-debug/pmd_reports/pmd.xml