Reputation: 567
I'm currently using Chrome's Developer Tools to create an array which contains every word in the Scrabble dictionary, which I can then use in my Scrabble predictor program. The dictionary can be found here: http://scrabblehelper.googlecode.com/svn-history/r20/trunk/ScrabbleHelper/src/dictionaries/sowpods.txt
So far, I've built a jQuery scraper which produces an array of 267,752 words. The code is simply:
var allWords = $('pre').innerText;
allWords = allWords.split('\n');
I hoped this might create a straightforward array which I could then copy straight into my program. However, instead, it structures the array - breaking it down into sections of [0-99], [100-199], which I can't simply copy over. Does anyone know how to stop Chrome from doing this, so that allWords
simply becomes an array in the format ["AARDVARK", "AARDWOLF", "ABACUS", ... ]
and so on?
When I simply copy the console.log
output, I get the following mess:
Array[267752][0 … 9999][0 … 99]0: "AA"1: "AAH"2: "AAHED"3: "AAHING"4: "AAHS"5: "AAL"6: "AALII"7: "AALIIS"8: "AALS"9: "AARDVARK"10: "AARDVARKS"11: "AARDWOLF"12: "AARDWOLVES"13: "AARGH"14: "AARRGH"15: "AARRGHH"16: "AARTI"17: "AARTIS"18: "AAS"19: "AASVOGEL"20: "AASVOGELS"21: "AB"22: "ABA"23: "ABAC"24: "ABACA"25: "ABACAS"26: "ABACI"27: "ABACK"28: "ABACS"29: "ABACTERIAL"30: "ABACTINAL"31: "ABACTINALLY"32: "ABACTOR"33: "ABACTORS"34: "ABACUS"35: "ABACUSES"36: "ABAFT"37: "ABAKA"38: "ABAKAS"39: "ABALONE"40: "ABALONES"41: "ABAMP"42: "ABAMPERE"43: "ABAMPERES"44: "ABAMPS"45: "ABAND"46: "ABANDED"47: "ABANDING"48: "ABANDON"49: "ABANDONED"50: "ABANDONEDLY"51: "ABANDONEE"52: "ABANDONEES"53: "ABANDONER"54: "ABANDONERS"55: "ABANDONING"56: "ABANDONMENT"57: "ABANDONMENTS"58: "ABANDONS"59: "ABANDONWARE"60: "ABANDONWARES"61: "ABANDS"62: "ABAPICAL"63: "ABAS"64: "ABASE"65: "ABASED"66: "ABASEDLY"67: "ABASEMENT"68: "ABASEMENTS"69: "ABASER"70: "ABASERS"71: "ABASES"72: "ABASH"73: "ABASHED"74: "ABASHEDLY"75: "ABASHES"76: "ABASHING"77: "ABASHLESS"78: "ABASHMENT"79: "ABASHMENTS"80: "ABASIA"81: "ABASIAS"82: "ABASING"83: "ABASK"84: "ABATABLE"85: "ABATE"86: "ABATED"87: "ABATEMENT"88: "ABATEMENTS"89: "ABATER"90: "ABATERS"91: "ABATES"92: "ABATING"93: "ABATIS"94: "ABATISES"95: "ABATOR"96: "ABATORS"97: "ABATTIS"98: "ABATTISES"99: "ABATTOIR"[100 … 199][200 … 299][300 … 399][400 … 499][500 … 599][600 … 699][700 … 799][800 … 899][900 … 999][1000 … 1099][1100 … 1199][1200 … 1299][1300 … 1399][1400 … 1499][1500 … 1599][1600 … 1699][1700 … 1799][1800 … 1899][1900 … 1999][2000 … 2099][2100 … 2199][2200 … 2299][2300 … 2399][2400 … 2499][2500 … 2599][2600 … 2699][2700 … 2799][2800 … 2899][2900 … 2999][3000 … 3099][3100 … 3199][3200 … 3299][3300 … 3399][3400 … 3499][3500 … 3599][3600 … 3699][3700 … 3799][3800 … 3899][3900 … 3999][4000 … 4099][4100 … 4199][4200 … 4299][4300 … 4399][4400 … 4499][4500 … 4599][4600 … 4699][4700 … 4799][4800 … 4899][4900 … 4999][5000 … 5099][5100 … 5199][5200 … 5299][5300 … 5399][5400 … 5499][5500 … 5599][5600 … 5699][5700 … 5799][5800 … 5899][5900 … 5999][6000 … 6099][6100 … 6199][6200 … 6299][6300 … 6399][6400 … 6499][6500 … 6599][6600 … 6699][6700 … 6799][6800 … 6899][6900 … 6999][7000 … 7099][7100 … 7199][7200 … 7299][7300 … 7399][7400 … 7499][7500 … 7599][7600 … 7699][7700 … 7799][7800 … 7899][7900 … 7999][8000 … 8099][8100 … 8199][8200 … 8299][8300 … 8399][8400 … 8499][8500 … 8599][8600 … 8699][8700 … 8799][8800 … 8899][8900 … 8999][9000 … 9099][9100 … 9199][9200 … 9299][9300 … 9399][9400 … 9499][9500 … 9599][9600 … 9699][9700 … 9799][9800 … 9899][9900 … 9999][10000 … 19999][20000 … 29999][30000 … 39999][40000 … 49999][50000 … 59999][60000 … 69999][70000 … 79999][80000 … 89999][90000 … 99999][100000 … 109999][110000 … 119999][120000 … 129999][130000 … 139999][140000 … 149999][150000 … 159999][160000 … 169999][170000 … 179999][180000 … 189999][190000 … 199999][200000 … 209999][210000 … 219999][220000 … 229999][230000 … 239999][240000 … 249999][250000 … 259999][260000 … 267751]length: 267752__proto__: Array[0]
Upvotes: 2
Views: 1515
Reputation: 10981
Just use the copy
command from the console API. Combine it with the recommendation of JSON.stringify
to get a string representation of the array.
For example:
copy(JSON.stringify(document.querySelector('pre').innerText.split('\n')))
This will copy the contents directly to the clipboard, no fussing with manually copying it in any way.
Note: This is only available in the console. To do it from the web page, you will need something like clipboard.js. You can use the underlying technology using execCommand and selection APIs, but clipboard makes it so easy without much overhead.
Upvotes: 0
Reputation: 1645
Why don't you just run JSON.stringify() on your array, and copy the resulting string? Alternatively, you could use a script to insert the value of the array into an element on the page, and copy from that.
Upvotes: 0
Reputation: 154454
You can't, really. Chrome's dev tools is splitting the array up into chunks because generally when you're debugging it's more helpful to look only at a chunk than the whole thing.
You can use console.log(allWords.join(","))
if you simply want to see a comma-separated list of all the words.
Upvotes: 0
Reputation: 2274
It's not breaking it down into anything. It's just a normal array.
The developer tools chunk them in pieces to make it easier for you to read visually.
var allWords = $('pre').innerText;
allWords = allWords.split('\n');
allWords.length == some really big number
Upvotes: 3