Jump to content
Sign in to follow this  
stablish

[Script] Block gaming related websites

Recommended Posts

Hi all,

had something in my mind for overcoming the addiction and wrote a little script, which is for windows only currently but can be ported to Linux aswell - If you want/need it for Linux aswell, let me know.

What this script can do?
Blocking access to gaming related websites by adding them into the hosts file.

What this script can't do (yet)?
Blocking gaming software. It is planned to block clients such as steam, uplay, battle.net, but currently it only blocks the access to websites.

How to execute?
Make a text file on your desktop (or wherever you want) and paste the content/script into it.
Change the extension from .txt to .bat
Follow this link if you dont have file extensions enabled
Right click -> Execute as admin


This script also blocks access to twitch.tv.
If you still want to access twitch.tv, remove these lines:

 

(
echo.
echo 127.0.0.1 twitch.tv
echo 127.0.0.1 www.twitch.tv
) >> "%Hosts%"


And here is the script.
 

 
REM Very basic script to block gaming related websites
REM It will backup your current hosts file
REM And add gaming related websites
REM So you can't access them anymore


NET SESSION >nul 2>&1
IF %ERRORLEVEL% EQU 0 (
    ECHO ##################################
    ECHO Administrator PRIVILEGES Detected!
    ECHO ##################################
) ELSE (
   echo ######## ########  ########   #######  ########
   echo ##       ##     ## ##     ## ##     ## ##     ##
   echo ##       ##     ## ##     ## ##     ## ##     ##
   echo ######   ########  ########  ##     ## ########
   echo ##       ##   ##   ##   ##   ##     ## ##   ##
   echo ##       ##    ##  ##    ##  ##     ## ##    ##
   echo ######## ##     ## ##     ##  #######  ##     ##
   echo.
   echo.
   echo ####### ERROR: ADMINISTRATOR PRIVILEGES REQUIRED #########
   echo This script must be run as administrator to work properly!
   echo Right click on the file and select "Run as Administrator".
   echo ##########################################################
   echo.
   PAUSE
   EXIT /B 1
)

copy C:\Windows\System32\drivers\etc\hosts C:\Windows\System32\drivers\etc\hosts.bak

@echo off
TITLE Modifying your HOSTS file
COLOR 1F
echo.
Set "Hosts=%windir%\System32\drivers\etc\hosts"
Copy "%Hosts%" "%Hosts%.bak"
(
  echo # Steam related
  echo 127.0.0.1 steampowered.com
  echo 127.0.0.1 store.steampowered.com
  echo 127.0.0.1 steamcharts.com
  echo 127.0.0.1 steamcommunity.com
  echo 127.0.0.1 steam.tools
  echo 127.0.0.1 steam.design
  echo 127.0.0.1 steamdb.info
  echo 127.0.0.1 steamspy.com
  echo 127.0.0.1 valvesoftware.com
  echo 127.0.0.1 www.valvesoftware.com
  echo.
  echo # Battle.net / Blizzard related
  echo 127.0.0.1 blizzard.com
  echo 127.0.0.1 www.blizzard.com
  echo 127.0.0.1 battle.net
  echo 127.0.0.1 www.battle.net
  echo 127.0.0.1 worldofwarcraft.com
  echo 127.0.0.1 playhearthstone.com
  echo 127.0.0.1 starcraft.com
  echo 127.0.0.1 starcraft2.com
  echo.
  echo # League of Legends related
  echo 127.0.0.1 riotgames.com
  echo 127.0.0.1 www.riotgames.com
  echo 127.0.0.1 leagueoflegends.com
  echo 127.0.0.1 www.leagueoflegends.com
  echo 127.0.0.1 lolesports.com
  echo 127.0.0.1 www.lolesports.com
  echo 127.0.0.1 lolalytics.com
  echo 127.0.0.1 lolmath.net
  echo 127.0.0.1 lolking.net
  echo 127.0.0.1 www.lolking.net
  echo 127.0.0.1 wol.gg
  echo 127.0.0.1 lolcounter.com
  echo 127.0.0.1 www.lolcounter.com
  echo.
  echo # NCSoft related
  echo 127.0.0.1 ncsoft.com
  echo 127.0.0.1 www.ncsoft.com
  echo 127.0.0.1 bladeandsoul.com
  echo 127.0.0.1 www.bladeandsoul.com
  echo 127.0.0.1 aiononline.com
  echo 127.0.0.1 www.aiononline.com
  echo.
  echo # UPlay related
  echo 127.0.0.1 ubi.com
  echo 127.0.0.1 uplay.ubi.com
  echo 127.0.0.1 www.uplay.ubi.com
  echo 127.0.0.1 store.ubi.com
  echo 127.0.0.1 account.ubisoft.com
  echo 127.0.0.1 www.ubisoft.com
) > "%Hosts%"


REM Remove the lines below if you dont want to block twitch
(
echo.
echo 127.0.0.1 twitch.tv
echo 127.0.0.1 www.twitch.tv
) >> "%Hosts%"
REM Remove the lines above if you dont want to block twitch

REM Restarting network adapters
ipconfig /release
ipconfig /flushdns
ipconfig /renew

 



Let me know if you think such scripts are useful so I can work on it and improve it and also let me know if you need such script for Linux.

  • Like 3

Share this post


Link to post
Share on other sites

This is great! thanks so much!

Two suggestions:

Put it on github so people can add entries to it and improve it.

Make it so that it appends the entries to the existing hosts file, instead of replacing it

Share this post


Link to post
Share on other sites

Personally on Linux (or Mac) I just have 0.0.0.0 twitch.tv or 0.0.0.0 steampowered.com in my /etc/hosts

Edited by TayBN
Forgot to add the proper steam link

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...