

- #Js blocker extension w how to
- #Js blocker extension w software
- #Js blocker extension w code
- #Js blocker extension w download
- #Js blocker extension w mac
I am starting a new Open Source project named “Control-Yourself” which will be a desktop application made using Electron. Here is the test run: Yuss! We Made It ❤Īre you an open source enthusiast? Want to contribute to this project? Please note that just for checking purposes, I am blocking. If you are a Windows user, you can open the command prompt as administrator, go to the project directory, and then run the command: node blocker.js To run the script, open the present working directory in a terminal and type in the following command: sudo node blocker.js Therefore we will have to call the blocker function once before the setInterval function.

But, setInterval() will run for the first time after the specified delay. This keeps repeating the blocker function after a specific interval of time. Or, a better option is to use the setInterval() function. Inside it we can give some time delay so that it doesn't occupy the processor continuously.

We can also use while (true) as an infinite loop. To keep it running we will be using setInterval() method in JavaScript. Basically the idea is to keep the script running all the time to check whether it is the time to block/unblock the websites. This variable will store the value of time duration (in milliseconds) after which our script will repeat itself.

Setting up the variablesĪs I said earlier, there is no need of huge directory structuring or setting up of a dev environment.
#Js blocker extension w code
Now that we’ve checked that our concept is correct, let’s code the blocker. To check it, go to any web browser, and go to that website. Let’s try it out :)Īlright, so we appended our “to be blocked” website in the hosts file, now let’s check it out whether it worked or not. sudo nano /etc/hostsĪfter you type this command, it will ask you to enter your password. I am using nano to open the file, you can use any other editor of your choice. If you are using Linux, you can use the sudo command. If you are on Windows you can right click on that file and open as administrator. Please note that only the user with administrator rights can modify this file.
#Js blocker extension w mac
If you are a Mac or Linux user, the location of that file is: /etc/hosts.īefore starting the code, let’s try to modify the file and see if it works. The hosts file which I am talking about is present in C:\Windows\System32\drivers\etc\hosts if you use Windows. Something like this: 127.0.0.1 Now, whenever we try to open Facebook, it will be redirected to 127.0.0.1 (localhost) automatically. We can add the URL of any website and the URL of a website to which we want to redirect the former website to. The idea behind this blocker we are going to make is very simple. I chose JavaScript because I love it! I ❤️ JavaScript! (source: ) The Background Idea You can make this script using any language of your choice which supports file handling. All you need is NodeJS installed on your system and a good text editor. Unlike my other tutorial articles, you won’t need any directory structure or a dev environment set up for this project.
#Js blocker extension w download
If you want to download the script directly, you can do so from here. Well yeah, quite easy! But come on, we are developers, we don’t do these things! When we need something, we develop scripts for it rather than using some random trick to do the work…right?!
#Js blocker extension w software
Just download some Chrome plugin, or rather any software which would do this for us. Yes, I know there are many easy methods to block any website. How about making a script which would block all these websites? The script allows you to use them only at some specific given hours of a day. It came into my mind, why not make some script which would help me limit the amount of time I spend on these websites? Stop scrolling through your feed, and do something xD (source: ) I hated it! I had to do something about it. I found that it had been been 4 hours since I’d been sitting at the same position and “Doing Nothing”. Tired of wasting your time on various unproductive websites? Why not make a script which would help you limit the time you spend on these websites?ĭoes this sound familiar…? Just another day, scrolling through my Social Media feed and watching memes.
#Js blocker extension w how to
By Madhav Bahl How to block unproductive websites and boost your productivity using JavaScript Time to get sh*t done :)
