thealphadollar / salvator Goto Github PK
View Code? Open in Web Editor NEWSalvator: The Saviour, When You Forget Birthdays
License: MIT License
Salvator: The Saviour, When You Forget Birthdays
License: MIT License
An npm module will be much better in setting up the cron job because it can help improve the user interface, the job can be set directly from the puppeteer-salvator
tool.
Since the .env file contains sensitive information like the username and password, it will be better to encrypt the .env file when stored on the users system.
This error occurred after i added the error handling features in the parseRawBirthdayData.js
file. The way salvator bot scrapes for birthday data is :
const raw_links = document.querySelector( "#birthdays_content > div:nth-child(1) > div:nth-child(2) > ul" ).innerHTML; const raw_names = document.querySelector( "#birthdays_content > div:nth-child(1) > div:nth-child(2) > ul" ).innerText;
The script tries to assign raw_links and raw_names variables even when document.querySelector() returns undefined. When the try catch blocks were not introduced, it resulted into a silent error and was ignored. But after the addition of try catch this results into an error and stops the program.
The messenger link is incorrectly resolved if friend's name contains 'id' in it (eg. nidhi). A possible solution is to search for '?id' instead of 'id' in resolveLinks function.
As i am making changes to the fuctions according to the es-lint errors, i find difficult to know if the functions will work properly or not after the changes i made. This task would have been much easier if there were unit tests written for these functions.
Currently, salvator sends messages to everyone (whose birthday is today) when
invoked irrespective of if that person was wished already in the previous run.
This can be improved by appending the link to messenger page of the person to a
file and at the time of sending check if it's already present there. That file
should also be flushed daily.
Add a scheduler to make the application all time running and execution being handled as a scheduled job.
The path where data.json
is saved is inside a folder which might not exist on
the user's PC and due to which it will give error.
This can be fixed by looking for the folder's existence and creating one if not
found.
It would be nice if the birthday wish is a random quote from a list.
This will help immensely in debugging. Insted of manually setting headless:false
in the newly created browser object and then going back and undoing it, one can simply run puppeteer-salvator run --watch
or puppeteer-salvator run -w
to set the headless:false
option.
Steps to recreate the Error:
node install.js
ERROR: Failed to download Chromium r609904! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download.
{ [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/puppeteer-salvator/node_modules/puppeteer/.local-chromium'] errno: -13, code: 'EACCES', syscall: 'mkdir', path: '/usr/local/lib/node_modules/puppeteer-salvator/node_modules/puppeteer/.local-chromium' }
3. so i try this instead: echo "export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true && npm install -g puppeteer-salvator" | sudo sh
4. INSTALLS successfully after skipping the download of Chromium.
5. But when i run the command puppeteer-salvator
in the terminal, gives command not found
.
Two factor authentication blocks the login when enabled. A possible solution can be to configure the .env file with a parameter detecting two -factor authentication state and thereby handle the case as needed.
Add a script to append periodically launching the script to cron.
E.g 5 0 * * * nodejs /path/to/index.js
If feasible, provide the script with all necessary commands from installation to adding to cron.
Currently the erros are not catched properly and hence when the system is
automated they are lost: catching them and printing them manually will solve
the issue.
Currently the method is independent of number of birthdays, which is a problem on days when there are no birthdays.
A simple solution for this would be adding an if statement to check length of the list of profile links.
For people who have already Chromium installed in their browsers, this causes an unnecessary installation and wastage of bandwith.
Add npm install puppeteer-salvator --ignore-scripts
in the README to avoid installing Chromium.
If a person's birthday was a day before, fb's birthday page(https://www.facebook.com/events/birthdays/) even shows the birthdays that were one day ago.
The getRawBirthdayData() function reads these birthdays as well.
Just as linux, we can create a single script installer for windows which will
install the client and add it to cron, asking the user just the time at which
the client should launch.
I am running the file on Ubuntu 16.04.4 LTS
. I installed node via nvm
(node version manager).
Even though node runs globally on my system it is not listed. So i suggest a better way of looking for node:
Inside the cron.sh
file you are doing dpkg-query -W --showformat='${Status}\n' nodejs|grep "install ok installed"
to check if node is installed or not. But later you are running which nodejs
to locate its install path. I suggest you directly check using which nodejs
or which node
(both) to look for node. If the output from the which
command results in an empty string then node/nodejs is not present on the system :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.