Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve dev tools to update browser variables list. #165

Closed
wants to merge 11 commits into from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
yarn.lock
browser_vars.json
22 changes: 12 additions & 10 deletions get-browser-globals.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
'use strict';

const fs = require('fs');

const { browser } = require('jshint/src/vars.js');


const blacklist = [
/^webkit/i,
'BeforeInstallPromptEvent',
Expand Down Expand Up @@ -42,8 +47,8 @@ const blacklist = [
'values'
];

const globals = Object.getOwnPropertyNames(window)
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
const globals = Object.getOwnPropertyNames(browser)
.sort((a, b) => a.localeCompare(b))
.filter(global => {
for (const pattern of blacklist) {
if (typeof pattern === 'string') {
Expand All @@ -65,11 +70,8 @@ for (const key of globals) {
ret[key] = key.startsWith('on');
}

copy(JSON.stringify(ret, null, '\t'));

/*

Usage:
Open an Incognito window in Chrome Canary and paste the above into the console. You'll now have a new object in your clipboard for the `browser` field in `globals.json`. You still need to manually filter out items from the `builtin` list.

*/
fs.writeFile('./browser_vars.json', JSON.stringify(ret, null, '\t'), (error) => {
if (error) {
return console.log(error);
}
});
Loading