Is it possible to turn off JavaScript within Chrome using a Windows application. I am using Windows 10.
-
Is there any possible way to do it.Anoop Mishra– Anoop Mishra2016-04-14 08:34:07 +00:00Commented Apr 14, 2016 at 8:34
-
2technipages.com/google-chrome-enable-or-disable-javascriptFᴀʀʜᴀɴ Aɴᴀᴍ– Fᴀʀʜᴀɴ Aɴᴀᴍ2016-04-14 08:50:03 +00:00Commented Apr 14, 2016 at 8:50
-
i dont find the application folder in chrome...Anoop Mishra– Anoop Mishra2016-04-14 08:54:45 +00:00Commented Apr 14, 2016 at 8:54
-
You have to specify that no JavaScript should be allowed when first starting chrome via the command line switch as above.Danny Cullen– Danny Cullen2016-04-14 10:10:13 +00:00Commented Apr 14, 2016 at 10:10
-
it doesnt work on windows 10.Anoop Mishra– Anoop Mishra2016-04-15 06:58:15 +00:00Commented Apr 15, 2016 at 6:58
2 Answers
For current chrome (ver. 57), using --user-data-dir command line switch:
chrome --user-data-dir=my_dir- Close chrome
- There is a file Preferences in
my_dir/Default/with JSON content. Add/change"default_content_setting_values":{"javascript":2}to key"profile". chrome --user-data-dir=my_diragain, with Javascript disabled.
Python 2.7 code:
import subprocess
import json
data_dir = r'h:\my-data-dir'
cmd = [r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", r"--user-data-dir=%s" % data_dir]
p = subprocess.Popen(cmd)
p.kill()
preferences_path = '%s/Default/Preferences' % data_dir
json_object = None
with open(preferences_path, 'r') as f:
json_object = json.loads(f.readline())
json_object['profile']['default_content_setting_values'] = {'javascript': 2}
with open(preferences_path, 'w') as f:
f.write(json.dumps(json_object))
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) # javascript disabled here
Comments
It can't be done with current versions because browser hijacking is actually a problem.
If you want to disable Javascript for your Windows organization, you can do so via Group Policies... there are ADM/ADMX administrative templates for the settings, which you can distribute via Active Directory or using the local policies in Windows: save the templates to C:\Windows\PolicyDefinitions and configure them using the local group policy editor (run gpedit.msc).
Other way would be making a Chrome extension and use the settings API, using javascript. You could easily add exceptions to all current tabs, but I'm pretty sure that you don't want that (you'd use chrome.contentSettings.javascript.set and set exceptions for all urls when a tab is open)