Skip to content

Commit

Permalink
change the way it gets browsers globals variables with get-browser-gl…
Browse files Browse the repository at this point in the history
  • Loading branch information
Yury Shapkarin committed Jul 6, 2020
1 parent 3c74fce commit 64a645b
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 637 deletions.
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
20 changes: 11 additions & 9 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,7 +47,7 @@ const blacklist = [
'values'
];

const globals = Object.getOwnPropertyNames(window)
const globals = Object.getOwnPropertyNames(browser)
.sort((a, b) => a.localeCompare(b))
.filter(global => {
for (const pattern of blacklist) {
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

0 comments on commit 64a645b

Please sign in to comment.