0

Is it possible to turn off JavaScript within Chrome using a Windows application. I am using Windows 10.

9
  • Is there any possible way to do it. Commented Apr 14, 2016 at 8:34
  • 2
    technipages.com/google-chrome-enable-or-disable-javascript Commented Apr 14, 2016 at 8:50
  • i dont find the application folder in chrome... Commented 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. Commented Apr 14, 2016 at 10:10
  • it doesnt work on windows 10. Commented Apr 15, 2016 at 6:58

2 Answers 2

2

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_dir again, 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
Sign up to request clarification or add additional context in comments.

Comments

1
+50

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.