forked from garrya100/Apple-ID-Creator-Universal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnterprise iOS Apple ID Creator iTunes 12 Universal Localisation.applescript
2244 lines (1840 loc) · 171 KB
/
Enterprise iOS Apple ID Creator iTunes 12 Universal Localisation.applescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--VERSION 1.2.0.20 see history at bottom of script
--TO DO:
-- localisation has changed in el cap, as forms have shifted a lot. AUS has been fixed.
--start localization Country Code
--Set country code to adapt script, code according to http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
--Set iTunesCountryCode to your country code by removing the -- at the front of the iTunesCountryCode
--Supported Countries
--United States = USA
--Poland = POL
--Great Britain GBR
--Australia = AUS
--New Zealand = NZL
--Sweden = SWE
--France = FRA
--Canada = CAN
--Fiji = FJI
--Papua New Guinea = PNG
--Solomon Islands = SLB
--Germany = DEU
--Netherlands = NPL
--Finland = FIN
--India = IND
--Spain = ESP
--Italy = ITL
--China = CHN
--Austria = DEU
--property iTunesCountryCode : "" --set for error trap set for those don't know they need to set the localisation, comment this one out when the locale is set
--property iTunesCountryCode : "USA"
--property iTunesCountryCode : "POL"
--property iTunesCountryCode : "GBR"
property iTunesCountryCode : "AUS"
--property iTunesCountryCode : "NZL"
--property iTunesCountryCode : "SWE"
--property iTunesCountryCode : "FRA"
--property iTunesCountryCode : "CAN"
--property iTunesCountryCode : "FJI"
--property iTunesCountryCode : "PNG"
--property iTunesCountryCode : "SLB"
--property iTunesCountryCode : "DEU"
--property iTunesCountryCode : "NPL"
--property iTunesCountryCode : "FIN"
--property iTunesCountryCode : "IND"
--property iTunesCountryCode : "ESP"
--property iTunesCountryCode : "ITL"
--property iTunesCountryCode : "CHN"
--end Country Code
--declare localisation variables here
global ibooksLinkLocation
global curCheckBox
global curExpectedElementString
global curExpectedElementLocation
global curTermsExpectedElementString
global curTermsExpectedElementLocation
global noOfResponses
global curCheckBoxNum
global curMonthPos
global curDayPos
global enableTitle
global curTitlePos
global curUserNameGroupPos
global curAddressGroupPos
global curCityFieldName
global curCityFieldPos
global curCityGroupPos
global enableCounty
global curCountyPos
global enableProvince
global curProvincePos
global curProvinceGroup
global enableState
global curStateGroup
global curStatePos
global enablePostcode
global curPostalCodeFieldName
global curPostalCodeFieldPos
global curPostalCodeFieldGroup
global curPhoneGroup
global curAreaCode
global curPhonePos
global curFamilyNameFirst
--Used for storing a list of encountered errors. Written to by various handlers, read by checkForErrors()
global errorList
set errorList to {}
--Used for controlling the running or abortion of the script. Handler will run as long as scriptAction is "Continue". Can also be set to "Abort" to end script, or "Skip User" to skip an individual user.
global scriptAction
set scriptAction to "Continue"
--Store the current user number (based off line number in CSV file)
global currentUser
set currentUserNumber to 0
--Used for completing every step in the process, except actually creating the Apple ID. Also Pauses the script at various locations so the user can verify everything is working properly.
property dryRun : true
--Used to Log Results and Skip users automatically, so you don't have to baby sit a large AppleID creation session. Writes a CSV to csvOutFile - on the desktop. Then you can filter and re-run
property logAndSkipUsers : true
global csvOutFile
global resultString
property logAndSkipDelay : 1
set datestring to do shell script "date \"+%F_%H-%M-%S\""
set csvOutFile to (path to desktop as text) & "AppleIDResults-" & datestring & ".csv"
--Open the csvOutFile / log in Console app so you can get some progress output, dependant on logAndSkipUsers true
property openLogFile : true
--Master delay timer for slowing the script down at specified sections. Usefull for tweaking the entire script's speed
property masterDelay : 1
--Maximum time (in seconds) the script will wait for a page to load before giving up and throwing an error
property netDelay : 180
--Used at locations in script that will be vulnerable to slow processing. Multiplied by master delay. Tweak for slow machines. May be added to Net Delay.
property processDelay : 1
--How often should the script check that something has loaded/is ready
property checkFrequency : 0.5
--Used to store supported iTunes versions
property supportedItunesVersions : {"12.3.0", "12.3.1", "12.3.2", "12.3.3"}
property supportedOSVersions : {"10.11.1", "10.11.2", "10.11.3", "10.11.4"}
--Used for checking if iTunes is loading a page
property itunesAccessingString : "Accessing iTunes Store…"
--Used for error checking Page 1 if email address or password is rejected. Simply counts the elements and it the warning box pops up UI elements increase by one
global elementCountDefault
set elementCountDefault to 0
global elementPasswordCountDefault
set elementPasswordCountDefault to 0
global elementEmailCountDefault
set elementEmailCountDefault to 0
--Used to set difference in store type names after 12.2
global storetype
set storetype to "Store"
--Start localistaion settings
--Error trap for those who haven't set the localisation, a bit nicer than just bailing out of the script
if iTunesCountryCode is "" then
set scriptAction to button returned of (display dialog "Localisation has not been set, please set localisation at the top of the script by removing the -- infront of the property iTunesCountryCode you wish to use before re-running script" buttons {"Abort"} default button "Abort") as text
if scriptAction is "Abort" then return
end if
--localisation settings go in here, easier than having to scroll through the entire script to find them! You can cut any out that you don't need
if iTunesCountryCode is "USA" then
set ibooksLinkLocation to "itms://itunes.apple.com/us/app/ibooks/id364709193?mt=8"
set curExpectedElementString to "Welcome to the iTunes Store"
set curExpectedElementLocation to "Welcome to the iTunes Store"
set curTermsExpectedElementString to "Terms and Conditions and Apple Privacy Policy"
set curTermsExpectedElementLocation to "Terms and Conditions and Apple Privacy Policy"
set curCheckBox to 1
set curCheckBoxNum to 5
set noOfResponses to 6
set curMonthPos to 1
set curDayPos to 2
set enableTitle to true
set curTitlePos to 8
set curUserNameGroupPos to 9
set curAddressGroupPos to 10
set curCityFieldName to "City"
set curCityFieldPos to 1
set curCityGroupPos to 11
set enableProvince to false
set enableCounty to false
set enableState to true
set curStateGroup to 11
set curStatePos to 2
set enablePostcode to true
set curPostalCodeFieldName to "Zip"
set curPostalCodeFieldPos to 3
set curPostalCodeFieldGroup to 11
set curPhoneGroup to 12
set curAreaCode to true
set curPhonePos to 2
set curFamilyNameFirst to false
end if
if iTunesCountryCode is "POL" then
set ibooksLinkLocation to "itms://itunes.apple.com/pl/app/ibooks/id364709193?mt=8"
set curExpectedElementString to "Witamy w sklepie iTunes Store"
set curExpectedElementLocation to "Witamy w sklepie iTunes Store"
set curTermsExpectedElementString to "Warunki oraz Ochrona prywatności firmy Apple"
set curTermsExpectedElementLocation to "Warunki oraz Ochrona prywatności firmy Apple"
set curCheckBox to 1
set curCheckBoxNum to 6
set noOfResponses to 5
set curMonthPos to 2
set curDayPos to 1
set enableTitle to true
set curTitlePos to 8
set curUserNameGroupPos to 9
set curAddressGroupPos to 10
set curCityFieldName to "Town"
set curCityFieldPos to 2
set curCityGroupPos to 11
set enableProvince to false
set enableCounty to false
set enableState to false
set curStateGroup to 12
set curStatePos to 2
set enablePostcode to true
set curPostalCodeFieldName to "Postcode"
set curPostalCodeFieldPos to 1
set curPostalCodeFieldGroup to 11
set curPhoneGroup to 12
set curAreaCode to true
set curPhonePos to 2
set curFamilyNameFirst to false
end if
if iTunesCountryCode is "AUS" then
set ibooksLinkLocation to "itms://itunes.apple.com/au/app/ibooks/id364709193?mt=8"
set curExpectedElementString to "Welcome to the iTunes Store"
set curExpectedElementLocation to "Welcome to the iTunes Store"
set curTermsExpectedElementString to "Terms and Conditions and Apple Privacy Policy"
set curTermsExpectedElementLocation to "Terms and Conditions and Apple Privacy Policy"
set curCheckBox to 1
set curCheckBoxNum to 5
set noOfResponses to 7
set curMonthPos to 2
set curDayPos to 1
set enableTitle to true
set curTitlePos to 7
set curUserNameGroupPos to 8
set curAddressGroupPos to 9
set curCityFieldName to "City"
set curCityFieldPos to 2
set curCityGroupPos to 10
set enableProvince to false
set enableCounty to false
set enableState to true
set curStateGroup to 11
set curStatePos to 1
set enablePostcode to true
set curPostalCodeFieldName to "Postcode"
set curPostalCodeFieldPos to 1
set curPostalCodeFieldGroup to 10
set curPhoneGroup to 12
set curAreaCode to true
set curPhonePos to 2
set curFamilyNameFirst to false
end if
if iTunesCountryCode is "GBR" then
set ibooksLinkLocation to "itms://itunes.apple.com/gb/app/ibooks/id364709193?mt=8"
set curExpectedElementString to "Welcome to the iTunes Store"
set curExpectedElementLocation to "Welcome to the iTunes Store"
set curTermsExpectedElementString to "Terms and Conditions and Apple Privacy Policy"
set curTermsExpectedElementLocation to "Terms and Conditions and Apple Privacy Policy"
set curCheckBox to 1
set curCheckBoxNum to 6
set noOfResponses to 7
set curMonthPos to 2
set curDayPos to 1
set enableTitle to true
set curTitlePos to 8
set curUserNameGroupPos to 9
set curAddressGroupPos to 10
set curCityFieldName to "Town"
set curCityFieldPos to 1
set curCityGroupPos to 11
set enableCounty to true
set curCountyPos to 12
set enableProvince to false
set enableState to false
set curStateGroup to 12
set curStatePos to 1
set enablePostcode to true
set curPostalCodeFieldName to "Postcode"
set curPostalCodeFieldPos to 2
set curPostalCodeFieldGroup to 12
set curPhoneGroup to 13
set curAreaCode to true
set curPhonePos to 2
set curFamilyNameFirst to false
end if
if iTunesCountryCode is "NZL" then
set ibooksLinkLocation to "itms://itunes.apple.com/nz/app/ibooks/id364709193?mt=8"
set curExpectedElementString to "Welcome to the iTunes Store"
set curExpectedElementLocation to "Welcome to the iTunes Store"
set curTermsExpectedElementString to "Terms and Conditions and Apple Privacy Policy"
set curTermsExpectedElementLocation to "Terms and Conditions and Apple Privacy Policy"
set curCheckBox to 1
set curCheckBoxNum to 5
set noOfResponses to 6
set curMonthPos to 2
set curDayPos to 1
set enableTitle to true
set curTitlePos to 8
set curUserNameGroupPos to 9
set curAddressGroupPos to 10
set curCityFieldName to "City"
set curCityFieldPos to 2
set curCityGroupPos to 12
set enableProvince to false
set enableCounty to true
set curCountyPos to 11
set enableState to false
set curStateGroup to 11
set curStatePos to 2
set enablePostcode to true
set curPostalCodeFieldName to "Postcode"
set curPostalCodeFieldPos to 1
set curPostalCodeFieldGroup to 12
set curPhoneGroup to 13
set curAreaCode to true
set curPhonePos to 2
set curFamilyNameFirst to false
end if
if iTunesCountryCode is "SWE" then
set ibooksLinkLocation to "itms://itunes.apple.com/se/app/ibooks/id364709193?mt=8"
set curExpectedElementString to "VŠlkommen till iTunes Store"
set curExpectedElementLocation to "VŠlkommen till iTunes Store"
set curTermsExpectedElementString to "Villkor och Apples integritetspolicy"
set curTermsExpectedElementLocation to "Villkor och Apples integritetspolicy"
set curCheckBox to 1
set curCheckBoxNum to 6
set noOfResponses to 5
set curMonthPos to 2
set curDayPos to 1
set enableTitle to false
set curTitlePos to 7
set curUserNameGroupPos to 8
set curAddressGroupPos to 9
set curCityFieldName to "Town"
set curCityFieldPos to 2
set curCityGroupPos to 10
set enableProvince to false
set enableCounty to false
set enableState to false
set curStateGroup to 11
set curStatePos to 2
set enablePostcode to true
set curPostalCodeFieldName to "Postcode"
set curPostalCodeFieldPos to 1
set curPostalCodeFieldGroup to 10
set curPhoneGroup to 11
set curAreaCode to true
set curPhonePos to 2
set curFamilyNameFirst to false
end if
if iTunesCountryCode is "FRA" then
set ibooksLinkLocation to "itms://itunes.apple.com/fr/app/ibooks/id364709193?mt=8"
set curExpectedElementString to "Welcome to the iTunes Store"
set curExpectedElementLocation to "Welcome to the iTunes Store"
set curTermsExpectedElementString to "Terms and Conditions and Apple Privacy Policy"
set curTermsExpectedElementLocation to "Terms and Conditions and Apple Privacy Policy"
set curCheckBox to 1
set curCheckBoxNum to 6
set noOfResponses to 5
set curMonthPos to 2
set curDayPos to 1
set enableTitle to true
set curTitlePos to 8
set curUserNameGroupPos to 9
set curAddressGroupPos to 10
set curCityFieldName to "Town"
set curCityFieldPos to 2
set curCityGroupPos to 11
set enableProvince to false
set enableCounty to false
set enableState to false
set curStateGroup to 11
set curStatePos to 2
set enablePostcode to true
set curPostalCodeFieldName to "Postcode"
set curPostalCodeFieldPos to 1
set curPostalCodeFieldGroup to 11
set curPhoneGroup to 12
set curAreaCode to false
set curPhonePos to 1
set curFamilyNameFirst to false
end if
if iTunesCountryCode is "CAN" then
set ibooksLinkLocation to "itms://itunes.apple.com/ca/app/ibooks/id364709193?mt=8"
set curExpectedElementString to "Welcome to the iTunes Store"
set curExpectedElementLocation to "Welcome to the iTunes Store"
set curTermsExpectedElementString to "Terms and Conditions and Apple Privacy Policy"
set curTermsExpectedElementLocation to "Terms and Conditions and Apple Privacy Policy"
set curCheckBox to 1
set curCheckBoxNum to 4
set noOfResponses to 5
set curMonthPos to 2
set curDayPos to 1
set enableTitle to true
set curTitlePos to 8
set curUserNameGroupPos to 9
set curAddressGroupPos to 10
set curCityFieldName to "City"
set curCityFieldPos to 1
set curCityGroupPos to 11
set enableProvince to true
set curProvincePos to 2
set curProvinceGroup to 11
set enableCounty to false
set enableState to false
set curStateGroup to 11
set curStatePos to 2
set enablePostcode to true
set curPostalCodeFieldName to "Postcode"
set curPostalCodeFieldPos to 3
set curPostalCodeFieldGroup to 11
set curPhoneGroup to 12
set curAreaCode to true
set curPhonePos to 2
set curFamilyNameFirst to false
end if
if iTunesCountryCode is "FJI" then
set ibooksLinkLocation to "itms://itunes.apple.com/fj/app/ibooks/id364709193?mt=8"
set curExpectedElementString to "Welcome to the iTunes Store"
set curExpectedElementLocation to "Welcome to the iTunes Store"
set curTermsExpectedElementString to "Terms and Conditions and Apple Privacy Policy"
set curTermsExpectedElementLocation to "Terms and Conditions and Apple Privacy Policy"
set curCheckBox to 1
set curCheckBoxNum to 5
set noOfResponses to 5
set curMonthPos to 2
set curDayPos to 1
set enableTitle to true
set curTitlePos to 8
set curUserNameGroupPos to 9
set curAddressGroupPos to 10
set curCityFieldName to "Town"
set curCityFieldPos to 1
set curCityGroupPos to 11
set enableProvince to false
set enableCounty to false
set enableState to false
set curStateGroup to 11
set curStatePos to 2
set enablePostcode to false
set curPostalCodeFieldName to "Postcode"
set curPostalCodeFieldPos to 3
set curPostalCodeFieldGroup to 11
set curPhoneGroup to 12
set curAreaCode to false
set curPhonePos to 1
set curFamilyNameFirst to false
end if
if iTunesCountryCode is "PNG" then
set ibooksLinkLocation to "itms://itunes.apple.com/pg/app/ibooks/id364709193?mt=8"
set curExpectedElementString to "Welcome to the iTunes Store"
set curExpectedElementLocation to "Welcome to the iTunes Store"
set curTermsExpectedElementString to "Terms and Conditions and Apple Privacy Policy"
set curTermsExpectedElementLocation to "Terms and Conditions and Apple Privacy Policy"
set curCheckBox to 1
set curCheckBoxNum to 5
set noOfResponses to 5
set curMonthPos to 2
set curDayPos to 1
set enableTitle to false
set curTitlePos to 7
set curUserNameGroupPos to 8
set curAddressGroupPos to 9
set curCityFieldName to "Town"
set curCityFieldPos to 1
set curCityGroupPos to 10
set enableProvince to true
set curProvinceGroup to 10
set curProvincePos to 3
set enableCounty to false
set enableState to false
set curStateGroup to 11
set curStatePos to 2
set enablePostcode to false
set curPostalCodeFieldName to "Postcode"
set curPostalCodeFieldPos to 2
set curPostalCodeFieldGroup to 10
set curPhoneGroup to 11
set curAreaCode to false
set curPhonePos to 1
set curFamilyNameFirst to false
end if
if iTunesCountryCode is "SLB" then
set ibooksLinkLocation to "itms://itunes.apple.com/sb/app/ibooks/id364709193?mt=8"
set curExpectedElementString to "Welcome to the iTunes Store"
set curExpectedElementLocation to "Welcome to the iTunes Store"
set curTermsExpectedElementString to "Terms and Conditions and Apple Privacy Policy"
set curTermsExpectedElementLocation to "Terms and Conditions and Apple Privacy Policy"
set curCheckBox to 1
set curCheckBoxNum to 5
set noOfResponses to 5
set curMonthPos to 2
set curDayPos to 1
set enableTitle to true
set curTitlePos to 6
set curUserNameGroupPos to 7
set curAddressGroupPos to 8
set curCityFieldName to "Town"
set curCityFieldPos to 1
set curCityGroupPos to 10
set enableProvince to true
set curProvinceGroup to 9
set curProvincePos to 1
set enableCounty to false
set enableState to false
set curStateGroup to 11
set curStatePos to 2
set enablePostcode to false
set curPostalCodeFieldName to "Postcode"
set curPostalCodeFieldPos to 2
set curPostalCodeFieldGroup to 10
set curPhoneGroup to 10
set curAreaCode to false
set curPhonePos to 1
set curFamilyNameFirst to false
end if
if iTunesCountryCode is "DEU" then
set ibooksLinkLocation to "itms://itunes.apple.com/de/app/ibooks/id364709193?mt=8"
set curExpectedElementString to "Welcome to the iTunes Store"
set curExpectedElementLocation to "Welcome to the iTunes Store"
set curTermsExpectedElementString to "Terms and Conditions and Apple Privacy Policy"
set curTermsExpectedElementLocation to "Terms and Conditions and Apple Privacy Policy"
set curCheckBox to 1
set curCheckBoxNum to 6
set noOfResponses to 5
set curMonthPos to 2
set curDayPos to 1
set enableTitle to true
set curTitlePos to 8
set curUserNameGroupPos to 9
set curAddressGroupPos to 10
set curCityFieldName to "Town"
set curCityFieldPos to 2
set curCityGroupPos to 11
set enableProvince to false
set enableCounty to false
set enableState to false
set curStateGroup to 11
set curStatePos to 2
set enablePostcode to true
set curPostalCodeFieldName to "Zip"
set curPostalCodeFieldPos to 1
set curPostalCodeFieldGroup to 11
set curPhoneGroup to 12
set curAreaCode to true
set curPhonePos to 2
set curFamilyNameFirst to false
end if
if iTunesCountryCode is "NPL" then
set ibooksLinkLocation to "itms://itunes.apple.com/nl/app/ibooks/id364709193?mt=8"
set curExpectedElementString to "Welcome to the iTunes Store"
set curExpectedElementLocation to "Welcome to the iTunes Store"
set curTermsExpectedElementString to "Terms and Conditions and Apple Privacy Policy"
set curTermsExpectedElementLocation to "Terms and Conditions and Apple Privacy Policy"
set curCheckBox to 1
set curCheckBoxNum to 6
set noOfResponses to 5
set curMonthPos to 2
set curDayPos to 1
set enableTitle to true
set curTitlePos to 8
set curUserNameGroupPos to 9
set curAddressGroupPos to 10
set curCityFieldName to "Town"
set curCityFieldPos to 2
set curCityGroupPos to 11
set enableProvince to false
set enableCounty to false
set enableState to false
set curStateGroup to 11
set curStatePos to 2
set enablePostcode to true
set curPostalCodeFieldName to "Postcode"
set curPostalCodeFieldPos to 1
set curPostalCodeFieldGroup to 11
set curPhoneGroup to 12
set curAreaCode to true
set curPhonePos to 2
set curFamilyNameFirst to false
end if
if iTunesCountryCode is "FIN" then
set ibooksLinkLocation to "itms://itunes.apple.com/fi/app/ibooks/id364709193?mt=8"
set curExpectedElementString to "Welcome to the iTunes Store"
set curExpectedElementLocation to "Welcome to the iTunes Store"
set curTermsExpectedElementString to "Käyttöehdot ja Applen tietosuojakäytäntö"
set curTermsExpectedElementLocation to "Käyttöehdot ja Applen tietosuojakäytäntö"
set curCheckBox to 1
set curCheckBoxNum to 6
set noOfResponses to 5
set curMonthPos to 2
set curDayPos to 1
set enableTitle to false
set curTitlePos to 7
set curUserNameGroupPos to 8
set curAddressGroupPos to 9
set curCityFieldName to "Town"
set curCityFieldPos to 2
set curCityGroupPos to 10
set enableProvince to false
set enableCounty to false
set enableState to false
set curStateGroup to 11
set curStatePos to 2
set enablePostcode to true
set curPostalCodeFieldName to "Postcode"
set curPostalCodeFieldPos to 1
set curPostalCodeFieldGroup to 10
set curPhoneGroup to 11
set curAreaCode to true
set curPhonePos to 2
set curFamilyNameFirst to false
end if
if iTunesCountryCode is "IND" then
set ibooksLinkLocation to "itms://itunes.apple.com/in/app/ibooks/id364709193?mt=8"
set curExpectedElementString to "Welcome to the iTunes Store"
set curExpectedElementLocation to "Welcome to the iTunes Store"
set curTermsExpectedElementString to "Terms and Conditions and Apple Privacy Policy"
set curTermsExpectedElementLocation to "Terms and Conditions and Apple Privacy Policy"
set curCheckBox to 1
set curCheckBoxNum to 5
set noOfResponses to 5
set curMonthPos to 2
set curDayPos to 1
set enableTitle to true
set curTitlePos to 8
set curUserNameGroupPos to 9
set curAddressGroupPos to 10
set curCityFieldName to "Town"
set curCityFieldPos to 1
set curCityGroupPos to 11
set enableProvince to false
set enableCounty to false
set enableState to false
set curStateGroup to 11
set curStatePos to 1
set enablePostcode to true
set curPostalCodeFieldName to "Postcode"
set curPostalCodeFieldPos to 2
set curPostalCodeFieldGroup to 11
set curPhoneGroup to 12
set curAreaCode to true
set curPhonePos to 2
set curFamilyNameFirst to false
end if
if iTunesCountryCode is "ESP" then
set ibooksLinkLocation to "itms://itunes.apple.com/es/app/ibooks/id364709193?mt=8"
set curExpectedElementString to "Welcome to the iTunes Store"
set curExpectedElementLocation to "Welcome to the iTunes Store"
set curTermsExpectedElementString to "Terms and Conditions and Apple Privacy Policy"
set curTermsExpectedElementLocation to "Terms and Conditions and Apple Privacy Policy"
set curCheckBox to 1
set curCheckBoxNum to 6
set noOfResponses to 5
set curMonthPos to 2
set curDayPos to 1
set enableTitle to true
set curTitlePos to 8
set curUserNameGroupPos to 9
set curAddressGroupPos to 10
set curCityFieldName to "Town"
set curCityFieldPos to 2
set curCityGroupPos to 11
set enableProvince to false
set enableCounty to false
set enableState to true
set curStateGroup to 12
set curStatePos to 1
set enablePostcode to true
set curPostalCodeFieldName to "Postcode"
set curPostalCodeFieldPos to 1
set curPostalCodeFieldGroup to 11
set curPhoneGroup to 13
set curAreaCode to false
set curPhonePos to 1
set curFamilyNameFirst to false
end if
if iTunesCountryCode is "ITL" then
set ibooksLinkLocation to "itms://itunes.apple.com/es/app/ibooks/id364709193?mt=8"
set curExpectedElementString to "Welcome to the iTunes Store"
set curExpectedElementLocation to "Welcome to the iTunes Store"
set curTermsExpectedElementString to "Terms and Conditions and Apple Privacy Policy"
set curTermsExpectedElementLocation to "Terms and Conditions and Apple Privacy Policy"
set curCheckBox to 1
set curCheckBoxNum to 6
set noOfResponses to 5
set curMonthPos to 2
set curDayPos to 1
set curYearPos to 3
set enableTitle to true
set curTitlePos to 8
set curUserNameGroupPos to 9
set curAddressGroupPos to 10
set curCityFieldName to "Town"
set curCityFieldPos to 2
set curCityGroupPos to 11
set enableProvince to false
set enableCounty to false
set enableState to true
set curStateGroup to 12
set curStatePos to 1
set enablePostcode to true
set curPostalCodeFieldName to "Postcode"
set curPostalCodeFieldPos to 1
set curPostalCodeFieldGroup to 11
set curPhoneGroup to 13
set curAreaCode to true
set curPhonePos to 2
set curFamilyNameFirst to false
set curFamilyNameFirst to false
end if
if iTunesCountryCode is "CHN" then
set ibooksLinkLocation to "itms://itunes.apple.com/cn/app/ibooks/id364709193?mt=8"
set curExpectedElementString to "Welcome to the iTunes Store"
set curExpectedElementLocation to "Welcome to the iTunes Store"
set curTermsExpectedElementString to "Terms and Conditions and Apple Privacy Policy"
set curTermsExpectedElementLocation to "Terms and Conditions and Apple Privacy Policy"
set curCheckBox to 1
set curCheckBox to 1
set curCheckBoxNum to 5
set noOfResponses to 5
set curMonthPos to 2
set curDayPos to 3
set curYearPos to 1
set enableTitle to false
set curTitlePos to 8
set curUserNameGroupPos to 6
set curAddressGroupPos to 7
set curCityFieldName to "Town"
set curCityFieldPos to 1
set curCityGroupPos to 8
set enableProvince to true
set enableCounty to false
set enableState to false
set curProvincePos to 2
set curProvinceGroup to 9
set enablePostcode to true
set curPostalCodeFieldName to "Postcode"
set curPostalCodeFieldPos to 1
set curPostalCodeFieldGroup to 9
set curPhoneGroup to 10
set curAreaCode to false
set curPhonePos to 1
set curFamilyNameFirst to true
end if
--end localization
-- only functions below this point, and data for iTunes "Get" button
(*
Email
Password
Secret Question 1
Secret Answer 1
Secret Question 2
Secret Answer 2
Secret Question 3
Secret Answer 3
Month Of Birth
Day Of Birth
Year Of Birth
First Name
Last Name
Address Street
Address City
Address State
Address Zip
Phone Area Code
Phone Number
Account Status
*)
--Properties for storing possible headers to check the source CSV file for. Source file will be checked for each of the items to locate the correct columns
property emailHeaders : {"Email", "Email Address"}
property passwordHeaders : {"Password", "Pass"}
property secretQuestion1Headers : {"Secret Question 1"}
property secretAnswer1Headers : {"Secret Answer 1"}
property secretQuestion2Headers : {"Secret Question 2"}
property secretAnswer2Headers : {"Secret Answer 2"}
property secretQuestion3Headers : {"Secret Question 3"}
property secretAnswer3Headers : {"Secret Answer 3"}
property monthOfBirthHeaders : {"Month", "Birth Month", "Month of Birth"}
property dayOfBirthHeaders : {"Day", "Birth Day", "Day Of Birth"}
property yearOfBirthHeaders : {"Year", "Birth Year", "Year Of Birth"}
property firstNameHeaders : {"First Name", "First", "fname"}
property lastNameHeaders : {"Last Name", "Last", "lname"}
property addressStreetHeaders : {"Street", "Street Address", "Address Street"}
property addressCityHeaders : {"City", "Address City"}
property addressStateHeaders : {"State", "Address State"}
property addressZipHeaders : {"Zip Code", "Zip", "Address Zip"}
property phoneAreaCodeHeaders : {"Area Code", "Phone Area Code"}
property phoneNumberHeaders : {"Phone Number", "Phone"}
property rescueEmailHeaders : {"Rescue Email (Optional)", "Rescue Email"}
property accountStatusHeaders : {"Account Status"} --Used to keep track of what acounts have been created
--Supported descriptions of iTunes free button
property supportedFreeButtonDescriptions : {"$0.00 Free, iBooks", "0,00 € Free, iBooks", "Free, iBooks", "£0.00 Free, iBooks", "$0.00 Get, iBooks", "0,00 € Get, iBooks", "£0.00 Get, iBooks", "Get, iBooks", "0,00 kr Get, iBooks", "USD 0.00 Get, iBooks", "€ 0,00 Get, iBooks", "€ 0,00 Download, iBooks", "$0.00 Download, iBooks", "£0.00 Download, iBooks", "₹ 0 Get, iBooks"}
set userDroppedFile to false
--Check to see if a file was dropped on this script
on open droppedFile
set userDroppedFile to true
MainMagic(userDroppedFile, droppedFile)
end open
--Launch the script in interactive mode if no file was dropped (if file was dropped on script, this will never be run, because of the "on open" above)
set droppedFile to ""
MainMagic(userDroppedFile, droppedFile)
--Main Function
on MainMagic(userDroppedFile, droppedFile)
--Donation Nag, maybe I can encourage a little good in the world!
-- set scriptAction to button returned of (display dialog "This script is donation ware. If you use this script, consider the many hours of work contributed by many people. " & return & return & "Show your appreciation by making a donation to a charity of your choice" buttons {"Continue"} default button "Continue") as text
--Check OS Version
set OSVersion to system version of (system info)
set OSVersionIsSupported to false
repeat with versionOSCheckLoopCounter from 1 to (count of items in supportedOSVersions)
if item versionOSCheckLoopCounter of supportedOSVersions is equal to OSVersion then
set OSVersionIsSupported to true
exit repeat
end if
end repeat
if OSVersionIsSupported is false then
set scriptAction to button returned of (display dialog "OSX is at version " & OSVersion & return & return & "It is unknown if this version of OSX will work with this script." & return & return & "You may abort now, or try running the script anyway." buttons {"Abort", "Continue"} default button "Abort") as text
end if
--Check iTunes Version
set itunesVersion to version of application "iTunes"
set itunesVersionIsSupported to false
if itunesVersion = "12.2.1" then set storetype to "Account"
repeat with versionCheckLoopCounter from 1 to (count of items in supportedItunesVersions)
if item versionCheckLoopCounter of supportedItunesVersions is equal to itunesVersion then
set itunesVersionIsSupported to true
exit repeat
end if
end repeat
if itunesVersionIsSupported is false then
set scriptAction to button returned of (display dialog "iTunes is at version " & itunesVersion & return & return & "It is unknown if this version of iTunes will work with this script." & return & return & "You may abort now, or try running the script anyway." buttons {"Abort", "Continue"} default button "Abort") as text
end if
if scriptAction is "Continue" then
--Load user file
set usersFile to loadUsersFile(userDroppedFile, droppedFile) --Load the users file. Returns a list of columns from the source file
if scriptAction is "Continue" then
--Split out header information from each of the columns
set headers to {}
repeat with headerRemoverLoopCounter from 1 to (count of items in usersFile)
set headers to headers & "" --Add an empty item to headers
set item headerRemoverLoopCounter of headers to item 1 of item headerRemoverLoopCounter of usersFile --Save the header from the column
set item headerRemoverLoopCounter of usersFile to (items 2 thru (count of items in item headerRemoverLoopCounter of usersFile) of item headerRemoverLoopCounter of usersFile) --Remove the header from the column
end repeat
set userCount to (count of items in item 1 of usersFile) --Counts the number of users
--seperated column contents (not really necessarry, but it makes everything else a whole lot more readable)
set appleIdEmailColumnContents to item 1 of usersFile
set appleIdPasswordColumnContents to item 2 of usersFile
set appleIdSecretQuestion1ColumnContents to item 3 of usersFile
set appleIdSecretAnswer1ColumnContents to item 4 of usersFile
set appleIdSecretQuestion2ColumnContents to item 5 of usersFile
set appleIdSecretAnswer2ColumnContents to item 6 of usersFile
set appleIdSecretQuestion3ColumnContents to item 7 of usersFile
set appleIdSecretAnswer3ColumnContents to item 8 of usersFile
set monthOfBirthColumnContents to item 9 of usersFile
set dayOfBirthColumnContents to item 10 of usersFile
set yearOfBirthColumnContents to item 11 of usersFile
set userFirstNameColumnContents to item 12 of usersFile
set userLastNameColumnContents to item 13 of usersFile
set addressStreetColumnContents to item 14 of usersFile
set addressCityColumnContents to item 15 of usersFile
set addressStateColumnContents to item 16 of usersFile
set addressZipColumnContents to item 17 of usersFile
set phoneAreaCodeColumnContents to item 18 of usersFile
set phoneNumberColumnContents to item 19 of usersFile
set appleIdRescueColumnContents to item 20 of usersFile
set accountStatusColumnContents to item 21 of usersFile
--Ask user if they want to perform a dry run, and give them a chance to cancel
set scriptRunMode to button returned of (display dialog "Would you like to preform a ''dry run'' of the script?" & return & return & "A ''dry run'' will run through every step, EXCEPT actually creating the Apple IDs." buttons {"Actually Create Apple IDs", "Dry Run", "Cancel"}) as text
if scriptRunMode is "Actually Create Apple IDs" then set dryRun to false
if scriptRunMode is "Dry Run" then set dryRun to true
if scriptRunMode is "Cancel" then set scriptAction to "Abort"
--Create ID's
if scriptAction is not "Abort" then
set accountStatusSetByCurrentRun to {}
set currentUserNumber to 0
repeat with loopCounter from 1 to userCount
-- if we are logging then we will create an output csv
if logAndSkipUsers is true then
-- write failed CSV file header
if not fileExists(csvOutFile) then
set csvHeader to "Email,Password,Secret Question 1,Secret Answer 1,Secret Question 2,Secret Answer 2,Secret Question 3,Secret Answer 3,Month Of Birth,Day Of Birth,Year Of Birth,First Name,Last Name,Address Street,Address City,Address State,Address Zip,Phone Area Code,Phone Number,Rescue Email (Optional),Result
"
set theResult to writeToCSV(csvOutFile, csvHeader, text, false)
if not theResult then
display dialog "error writing output to: " & csvOutFile
set scriptAction to "Abort"
end if
-- if we are want to open out log file in Console app
if openLogFile is true then
tell application "Console" to open csvOutFile
end if
end if
end if
--Increment our current user, just so other handlers can know what user we are on
set currentUserNumber to currentUserNumber + 1
--Get a single user's information from the column contents
set appleIdEmail to item loopCounter of appleIdEmailColumnContents
set appleIdPassword to item loopCounter of appleIdPasswordColumnContents
set appleIdSecretQuestion1 to item loopCounter of appleIdSecretQuestion1ColumnContents
set appleIdSecretAnswer1 to item loopCounter of appleIdSecretAnswer1ColumnContents
set appleIdSecretQuestion2 to item loopCounter of appleIdSecretQuestion2ColumnContents
set appleIdSecretAnswer2 to item loopCounter of appleIdSecretAnswer2ColumnContents
set appleIdSecretQuestion3 to item loopCounter of appleIdSecretQuestion3ColumnContents
set appleIdSecretAnswer3 to item loopCounter of appleIdSecretAnswer3ColumnContents
set rescueEmail to item loopCounter of appleIdRescueColumnContents
set monthOfBirth to item loopCounter of monthOfBirthColumnContents
set dayOfBirth to item loopCounter of dayOfBirthColumnContents
set yearOfBirth to item loopCounter of yearOfBirthColumnContents
set userFirstName to item loopCounter of userFirstNameColumnContents
set userLastName to item loopCounter of userLastNameColumnContents
set addressStreet to item loopCounter of addressStreetColumnContents
set addressCity to item loopCounter of addressCityColumnContents
set addressState to item loopCounter of addressStateColumnContents
set addressZip to item loopCounter of addressZipColumnContents
set phoneAreaCode to item loopCounter of phoneAreaCodeColumnContents
set phoneNumber to item loopCounter of phoneNumberColumnContents
set accountStatus to item loopCounter of accountStatusColumnContents
delay masterDelay
--Signout Apple ID that is currently signed in (if any)