Skip to content

Instantly share code, notes, and snippets.

@giannisp
Last active April 24, 2017 05:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giannisp/573702636db91fc56b768c61f1d16b63 to your computer and use it in GitHub Desktop.
Save giannisp/573702636db91fc56b768c61f1d16b63 to your computer and use it in GitHub Desktop.
Automate HSTS domain delete action on Chrome (macOS)
#!/usr/bin/env osascript -l JavaScript
function run(domain) {
const Chrome = Application('Google Chrome');
Chrome.activate();
const window = Chrome.windows[0];
const tab = Chrome.Tab({
url: 'chrome://net-internals/#hsts',
});
window.tabs.push(tab);
delay(1);
Chrome.execute(tab, {
javascript: `document.getElementById('hsts-view-delete-input').value = '${domain}'`
});
delay(0.5);
Chrome.execute(tab, {
javascript: 'document.getElementById(\'hsts-view-delete-submit\').click()'
});
tab.close();
}
$ chmod +x hsts-delete-domain
$ ./hsts-delete-domain example.com
@giannisp
Copy link
Author

Since Chrome 58 support for Javascript has been disabled:
https://bugs.chromium.org/p/chromium/issues/detail?id=661810

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment