user_agent_generator 0.0.1pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +22 -0
- data/bin/user_agent_generator +7 -0
- data/lib/User_Agent_Generator/application.rb +64 -0
- data/lib/User_Agent_Generator/display.rb +12 -0
- data/lib/User_Agent_Generator/logic.rb +86 -0
- data/lib/User_Agent_Generator/output.rb +42 -0
- data/lib/user_agent_generator.rb +7 -0
- data/readme.md +42 -0
- data/user_agent_generator.gemspec +19 -0
- metadata +55 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9bdc1f867e9dd280208c1e5ffe9ee7b5257eae5a
|
4
|
+
data.tar.gz: 7d1d69b4c878f15b6db12c3db81632e1424d7ffe
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4b2d457bf2b4572410c2d23b68236d3417448a289f82b488f3b2bac7bffe4f5840f179b3db63c8cd15412df6ae468cfe38051c768b14a6862c90f3c20b99e365
|
7
|
+
data.tar.gz: e603f4e7f4639a2e695223bec3f54de5d3556ee84d3b58998847233612ee0a922dc8b729ceefaf19305744c27a7550fcfcc11b3c485bf983fc3402c1f58bdd69
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Korey Enright
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module UserAgentGenerator
|
2
|
+
# :nodoc:
|
3
|
+
class Application
|
4
|
+
def initialize(argv)
|
5
|
+
@options = parse_options(argv)
|
6
|
+
|
7
|
+
@display = UserAgentGenerator::Display.new(@options)
|
8
|
+
@logic = UserAgentGenerator::Logic.new(@options)
|
9
|
+
@output = UserAgentGenerator::Output.new(@options)
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
agent_strings = @logic.run
|
14
|
+
@display.render(@output.to_file(agent_strings))
|
15
|
+
end
|
16
|
+
|
17
|
+
def parse_options(argv)
|
18
|
+
options = {}
|
19
|
+
|
20
|
+
opt_parser = OptionParser.new do |opt|
|
21
|
+
opt.banner = 'Usage: user_agent_generater [OPTIONS]'
|
22
|
+
opt.separator ''
|
23
|
+
opt.separator 'Options'
|
24
|
+
|
25
|
+
opt.on('-w', '--windows', 'Use Windows OS') do
|
26
|
+
options[:windows] = true
|
27
|
+
end
|
28
|
+
|
29
|
+
opt.on('-a', '--android', 'Use Android Mobile OS') do
|
30
|
+
options[:android] = true
|
31
|
+
end
|
32
|
+
|
33
|
+
opt.on('-i', '--iOS', 'Use iOS Mobile OS') do
|
34
|
+
options[:iOS] = true
|
35
|
+
end
|
36
|
+
|
37
|
+
opt.on('-c', '--chrome', 'Use Chrome browser') do
|
38
|
+
options[:chrome] = true
|
39
|
+
end
|
40
|
+
|
41
|
+
opt.on('-f', '--firefox', 'Use Firefox browser') do
|
42
|
+
options[:firefox] = true
|
43
|
+
end
|
44
|
+
|
45
|
+
opt.on('-s', '--safari', 'Use Safari browser Note: mobile only') do
|
46
|
+
options[:safari] = true
|
47
|
+
end
|
48
|
+
|
49
|
+
opt.on('-v', '--version VERSION', 'Version number, REQUIRED') do |v|
|
50
|
+
options[:version] = v
|
51
|
+
end
|
52
|
+
|
53
|
+
opt.on_tail('-h', '--help', 'Print this help!') do
|
54
|
+
puts opt_parser
|
55
|
+
exit
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
opt_parser.parse!(argv)
|
60
|
+
|
61
|
+
options
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module UserAgentGenerator
|
2
|
+
# :nodoc:
|
3
|
+
class Logic
|
4
|
+
def initialize(options)
|
5
|
+
@options = options
|
6
|
+
end
|
7
|
+
|
8
|
+
def run
|
9
|
+
if @options[:windows]
|
10
|
+
windows
|
11
|
+
elsif @options[:android]
|
12
|
+
android
|
13
|
+
elsif @options[:iOS]
|
14
|
+
iOS
|
15
|
+
else
|
16
|
+
''
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def windows
|
21
|
+
string = 'Windows / '
|
22
|
+
string + browser
|
23
|
+
end
|
24
|
+
|
25
|
+
def android
|
26
|
+
string = 'Android / '
|
27
|
+
string + browser
|
28
|
+
end
|
29
|
+
|
30
|
+
def iOS
|
31
|
+
string = 'iOS / '
|
32
|
+
string + browser
|
33
|
+
end
|
34
|
+
|
35
|
+
def browser
|
36
|
+
if @options[:chrome]
|
37
|
+
chrome(@options[:version])
|
38
|
+
elsif @options[:firefox]
|
39
|
+
firefox(@options[:version])
|
40
|
+
elsif @options[:safari]
|
41
|
+
safari(@options[:version])
|
42
|
+
else
|
43
|
+
''
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def chrome(version)
|
48
|
+
string = "Chrome #{version[0, 2]}: Mozilla/5.0 () AppleWebKit/537.36 (KHTML, like Gecko) Chrome/#{version} Safari/537.36"
|
49
|
+
os_index = string.index('()') + 1
|
50
|
+
string = @options[:windows] ? string.insert(os_index, 'Windows NT 6.1; WOW64') : string
|
51
|
+
string = @options[:android] ? string.insert(os_index, 'Linux; 4.4.2; Nexus 4 Build/KOT49H') : string
|
52
|
+
if @options[:iOS]
|
53
|
+
string.insert(os_index, 'iPad; CPU OS 7_0_4 like Mac OS X')
|
54
|
+
mobile_index = (string.index('Safari') - 1)
|
55
|
+
string.insert(mobile_index, ' Mobile')
|
56
|
+
else
|
57
|
+
string
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def firefox(version)
|
62
|
+
fail ArgumentError.new('Firefox not compatible with iOS devices') if @options[:iOS]
|
63
|
+
string = "Firefox #{version[0, 2]}: Mozilla/5.0 () Gecko/ Firefox/#{version}"
|
64
|
+
os_index = string.index('()') + 1
|
65
|
+
if @options[:windows]
|
66
|
+
string = string.insert(os_index, "Windows NT 6.1; WOW64; rv:#{version[0, 2]}.0")
|
67
|
+
gecko_index = string.index('Gecko/') + 7
|
68
|
+
string.insert(gecko_index, '20100101')
|
69
|
+
elsif @options[:android]
|
70
|
+
string = string.insert(os_index, "Android; Mobile; rv:#{version[0, 2]}.0")
|
71
|
+
gecko_index = string.index('Gecko/') + 7
|
72
|
+
string.insert(gecko_index, "#{version}")
|
73
|
+
else
|
74
|
+
string
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def safari(version)
|
79
|
+
fail ArgumentError.new('Safari not compatible with Windows') \
|
80
|
+
if @options[:windows]
|
81
|
+
fail ArgumentError.new('Safari not compatible with Android devices') \
|
82
|
+
if @options[:android]
|
83
|
+
"Safari #{version[0]} (iPad; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/#{version} Mobile/11B554a Safari/9537.53"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module UserAgentGenerator
|
2
|
+
# :nodoc:
|
3
|
+
class Output
|
4
|
+
PATH_TO_WORKING_DIRECTORY = Dir.pwd
|
5
|
+
MESSAGE = "You can find the user agent strings in the path: \
|
6
|
+
#{PATH_TO_WORKING_DIRECTORY}/data/"
|
7
|
+
PATH = 'data/'
|
8
|
+
FILENAME = 'user_agent_strings.txt'
|
9
|
+
|
10
|
+
def initialize(options)
|
11
|
+
@options = options
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_file(agent_string)
|
15
|
+
output_to_render = MESSAGE
|
16
|
+
|
17
|
+
exists = File.exist?(PATH + FILENAME)
|
18
|
+
file = exists ? append_to_file : create_new_file
|
19
|
+
write_to_file(file, agent_string)
|
20
|
+
|
21
|
+
output_to_render << FILENAME
|
22
|
+
end
|
23
|
+
|
24
|
+
def append_to_file
|
25
|
+
File.open(PATH + FILENAME, 'a')
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_new_file
|
29
|
+
path = PATH
|
30
|
+
unless File.directory?(Dir.pwd + path)
|
31
|
+
FileUtils.mkdir_p(path)
|
32
|
+
end
|
33
|
+
|
34
|
+
path << FILENAME
|
35
|
+
File.new(path, 'w')
|
36
|
+
end
|
37
|
+
|
38
|
+
def write_to_file(file, agent_string)
|
39
|
+
file.puts(agent_string)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/readme.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# User Agent Generator
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
The User Agent Generator is a Command Line tool which will generate working user agent strings for use in the [User Agent Overrider by muzuiget](https://github.com/muzuiget/user_agent_overrider) extension in Firefox.
|
6
|
+
It will create user agent strings for Windows, Android, and iOS devices on Firefox, Chrome, and Safari
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Just unzip the file to any directory.
|
11
|
+
|
12
|
+
Make sure that Ruby is installed to your system.
|
13
|
+
|
14
|
+
Alternately, if ruby is installed, type 'gem install user_agent_generator'
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
If you are using a Windows machine, you will need to open a Ruby command prompt in the same folder as the one you unzipped this tool into.
|
19
|
+
|
20
|
+
E.g., /Path_to_folder/user_agent_generator
|
21
|
+
|
22
|
+
Then, you can type ruby bin/user_agent_generator into the command line followed by several options
|
23
|
+
|
24
|
+
-w --windows This will generate a string assuming a Windows, 64-bit OS
|
25
|
+
|
26
|
+
-a --android This will generate a string assuming an Android operating system
|
27
|
+
|
28
|
+
-i --iOS This will generate a string assuming an iPad is being used
|
29
|
+
|
30
|
+
-c --chrome This will generate a string using Chrome
|
31
|
+
|
32
|
+
-f --firefox This will generate a string using Firefox
|
33
|
+
|
34
|
+
-s --safari This will generate a string using Safari
|
35
|
+
|
36
|
+
-v --version This allows you to specify what version you are using
|
37
|
+
|
38
|
+
-h --help This will print out a help prompt
|
39
|
+
|
40
|
+
Do not use more than one browser option, or more than one OS option.
|
41
|
+
The Version option is necessary.
|
42
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'user_agent_generator'
|
5
|
+
s.version = '0.0.1pre'
|
6
|
+
s.executables << 'user_agent_generator'
|
7
|
+
s.date = '2015-12-01'
|
8
|
+
s.summary = "Creates User Agent strings"
|
9
|
+
s.description = "A very basic user agent generator for use with the user agent overrider extenstion in firefox"
|
10
|
+
s.authors = ["Korey Enright"]
|
11
|
+
s.email = ["kenright@iit.edu"]
|
12
|
+
s.files = FileList['lib/*',
|
13
|
+
'lib/user_agent_generator/*',
|
14
|
+
'bin/*',
|
15
|
+
'[A-Z]*'].to_a
|
16
|
+
s.homepage =
|
17
|
+
'https://github.com/korey-enright/user_agent_generator.git'
|
18
|
+
s.license = 'MIT'
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: user_agent_generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1pre
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Korey Enright
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A very basic user agent generator for use with the user agent overrider
|
14
|
+
extenstion in firefox
|
15
|
+
email:
|
16
|
+
- kenright@iit.edu
|
17
|
+
executables:
|
18
|
+
- user_agent_generator
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- LICENSE
|
23
|
+
- bin/user_agent_generator
|
24
|
+
- lib/User_Agent_Generator/application.rb
|
25
|
+
- lib/User_Agent_Generator/display.rb
|
26
|
+
- lib/User_Agent_Generator/logic.rb
|
27
|
+
- lib/User_Agent_Generator/output.rb
|
28
|
+
- lib/user_agent_generator.rb
|
29
|
+
- readme.md
|
30
|
+
- user_agent_generator.gemspec
|
31
|
+
homepage: https://github.com/korey-enright/user_agent_generator.git
|
32
|
+
licenses:
|
33
|
+
- MIT
|
34
|
+
metadata: {}
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.3.1
|
49
|
+
requirements: []
|
50
|
+
rubyforge_project:
|
51
|
+
rubygems_version: 2.4.5.1
|
52
|
+
signing_key:
|
53
|
+
specification_version: 4
|
54
|
+
summary: Creates User Agent strings
|
55
|
+
test_files: []
|