Is it possible to block URLs with Tasker?

I'd like to block different sites from 9-5 everyday.


In general, no. Tasker can't know when a URL is launched (my testing with the "Receive Intent" event had no success), nor does it have the necessary control over the browser to stop the page from loading.

That said, if I could find the time to get DolphinTasker published, then yes, you could do this with Dolphin Browser. But that's not an option at the moment.


You can if your device is rooted. You need to add the URLs in the hosts file (/etc/hosts) like: facecrook.com liveminmin.com

and so on.

Note that you'll have to remount (as rw) your /system first using the commands:

adb shell
mount -o remount,rw /system

Use an editor like ES Note Editor (comes with ES File Explorer) to do the editing and then remount the system in ro mode. Also, before editing, copy the default hosts file at some location say /sdcard/host_files/original/hosts and the modified hosts file at /sdcard/host_files/modified/hosts

Now with the Tasker:

  1. Create a time based profile as +Time and select your timing when you want URLs to be blocked.
  2. Create a task under the above profile and the action inside it should be +Code → Run Shell:
    • Type mount -o remount,rw /system in Command
    • Check Use Root
  3. Create a new action through +File → Copy File:
    • Tap the lens icon corresponding to From and select /sdcard/host_files/modified/hosts
    • Tap the lens icon corresponding to To and select /etc folder by holding it.
  4. Create another new action through +Code → Run Shell:
    • Type mount -o remount,ro /system in Command
    • Check Use Root
  5. Create this last action through +System → Reboot → select Normal in Type.
  6. Create another profile for the time you don't want URLs to be blocked using step1.
  7. Copy steps 2-5 and choose /sdcard/host_files/original/hosts in step 3 under From.
  8. Make Tasker an exception in any app (if you have) that disables Tasker from startup.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.