Skip to content

Commit 123810d

Browse files
committed
Merge pull request nutki#1 from michaeljb/master
Trying to catch up to Goko-Salvager...
2 parents c8fda9a + 8e8ff23 commit 123810d

31 files changed

+1508
-2790
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
.\#*
66
\#*
77
build/
8+
tmp/

Goko_Live_Log_Viewer.user.js

Lines changed: 0 additions & 1291 deletions
This file was deleted.

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
Dominion Online User Extension
2-
==============================
1+
Goko Salvager
2+
=============
33

44
Discuss the extension at the [Dominion Strategy forum](http://goo.gl/4muRB).
55

66

77
Installation
88
------------
99
- Chrome - [get it from the Chrome web store](http://goo.gl/Y9AK5)
10-
- Firefox - install [the main script](https://github.com/michaeljb/Goko-Live-Log-Viewer/raw/master/Goko_Live_Log_Viewer.user.js) as a [Greasemonkey](https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/) user script
10+
- Firefox - [Firefox Add-on Store](https://addons.mozilla.org/en-US/firefox/addon/goko-salvager/)
1111
- Opera - the extension is not currently available in the Opera store, but it may be added by downloading and unzipping the [project ZIP](https://github.com/michaeljb/Goko-Live-Log-Viewer/archive/master.zip) and following [these instructions](http://dev.opera.com/extension-docs/tut_basics.html#step_4_testing_your_extension)
12-
- Safari - [download the extension file](http://goo.gl/aSxi9), and double-click on it to add it to Safari
12+
- Safari - [download the extension file](http://goo.gl/1SJmbB), and double-click on it to add it to Safari
13+
14+
Contributors
15+
------------
16+
- philosophyguy
17+
- nutki
18+
- 1wheel
19+
- michaeljb
20+
- ragingduckd
21+
- yed (Zdenek Bouska)

Rakefile

Lines changed: 33 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -1,183 +1,55 @@
11
# encoding: UTF-8
22

3-
# chrome/src/manifest.json depends on VERSION and chrome/src/images/icon##.png (at least their names)
4-
# build/#{chrome_package} depends on chrome/src/manifest.json, chrome/src/images/*, @parser, @script
5-
6-
# build/#{safari_packge} depends on safari/src/*; safari/src/Info.plist depends on VERSION
7-
8-
# in chrome_dev, images/ and manifest.json depend on chrome/src/*
9-
10-
# :automatch depends on @automatch and @script -- need some way to detect if already inserted, or figure out how to do use both without just shoving it in
11-
12-
# how to organize? dev:automatch, dev:chrome, dev:safari, build, build:chrome, build:safari, version, etc.
13-
143
require 'rake/clean'
154

16-
CLEAN.include Dir.glob('./**/*~')
17-
CLEAN.include Dir.glob('./**/.*~')
18-
CLEAN.include 'images/'
19-
CLEAN.include 'manifest.json'
20-
CLEAN.include 'chrome/src/*.js'
5+
CLEAN.include 'tmp/*'
6+
CLEAN.include 'build/*/'
217
CLOBBER.include 'build/*'
228

23-
@script = 'Goko_Live_Log_Viewer.user.js'
24-
@parser = 'set_parser.js'
25-
@automatch = '../goko-dominion-tools/web/Goko_automatch.user.js'
26-
27-
# first line inside the main function of @script
28-
@start_of_foo = 13
29-
@end_of_foo = 1204
30-
31-
# content of the first line in @parser to import @script
32-
@import_start = " script.src = 'http://dom.retrobox.eu/js/1.0.0/set_parser.js';
33-
"
34-
35-
# content of the first line in @script after the importing of @parser is complete
36-
@after_import_end = " script.textContent = '('+ fn +')();';
37-
"
38-
39-
@host_line = ' host = "http://gokologs.drunkensailor.org";
40-
'
41-
42-
@localhost_line = ' host = "http://localhost";
43-
'
9+
SCRIPT = 'src/ext/Goko_Live_Log_Viewer.user.js'
10+
PARSER = 'src/dev/set_parser.js'
4411

45-
@name = 'Dominion-Online-User-Extension'
46-
@version = File.read('VERSION').strip
47-
@versioned_name = "#{@name}-#{@version}"
48-
49-
def insert_set_parser_into_main_script out_file_name
50-
out = File.new(out_file_name, 'w')
51-
File.open(@script) do |script|
52-
current_line = 1
53-
skip_this_line = false
54-
script.each_line do |line|
55-
out.write(File.read(@parser)) if current_line == @start_of_foo
56-
skip_this_line = true if line == @import_start
57-
skip_this_line = false if line == @after_import_end
58-
out.write(line) unless skip_this_line
59-
current_line += 1
60-
end
61-
end
62-
out.close
63-
end
64-
65-
def insert_automatch_into_main_script
66-
out = File.new('tmp', 'w')
67-
File.open(@script) do |script|
68-
current_line = 1
69-
script.each_line do |line|
70-
if current_line == @end_of_foo
71-
File.open(@automatch) do |automatch|
72-
automatch.each_line do |a_line|
73-
if a_line == @host_line
74-
out.write(@localhost_line)
75-
else
76-
out.write(a_line) unless a_line == "var foo = function () {
77-
" || a_line == "}; document.addEventListener ('DOMContentLoaded', foo);
78-
"
79-
end
80-
end
81-
end
82-
end
83-
out.write(line)
84-
current_line += 1
85-
end
86-
end
87-
out.close
88-
FileUtils.mv 'tmp', @script
89-
end
12+
CREATE_AND_SIGN = 'src/dev/createAndSign.sh'
13+
WRAPPER = 'src/dev/runInPageContext.js'
9014

15+
VERSION = 'VERSION'
9116

17+
CHROME_MANIFEST = 'chrome/manifest.json'
18+
CHROME_IMAGES = 'chrome/images/'
9219

20+
FIREFOX_PACKAGE = 'firefox/package.json'
9321

94-
# TODO: improve this version stuff: maybe use ruby's FileList to generate the file tasks, with a hash to map files to their version string functions
95-
def increment_version
96-
version_parts = @version.split('.')
97-
version_parts[2] = version_parts[2].to_i + 1
98-
version_parts.join('.')
99-
end
22+
SAFARI_INFO = 'safari/Info.plist'
23+
SAFARI_SETTINGS = 'safari/Settings.plist'
10024

101-
task :update_version, :new_version do |t, args|
102-
@version = args[:new_version] || increment_version
103-
File.open("VERSION", "w") {|f| f.puts @version}
25+
def get_version
26+
File.read(VERSION).strip
10427
end
10528

106-
def update_version_in_file old, new, target
107-
text = File.read(target)
108-
replace = text.gsub(/#{old}/, "#{new}")
109-
File.open(target, "w") {|f| f.puts replace}
29+
def replace_pattern_in_file(old_pattern, new_string, target)
30+
text = File.read(target).gsub(/#{old_pattern}/, "#{new_string}")
31+
File.open(target, 'w') { |f| f.puts text }
11032
end
11133

112-
file "chrome/src/manifest.json" => "VERSION" do |t|
113-
def manifest_version v
114-
"\"version\": \"#{v}\","
115-
end
116-
old_v_pattern = ".*"
117-
update_version_in_file (manifest_version old_v_pattern), (manifest_version @version), t.name
34+
def insert_set_parser_into_main_script(out_file_name)
35+
out = File.new(out_file_name, 'w')
36+
out.write(File.read(PARSER))
37+
out.write(File.read(SCRIPT))
38+
out.close
11839
end
11940

120-
file "safari/src/Info.plist" => "VERSION" do |t|
121-
def info_version v
122-
" <key>CFBundleShortVersionString</key>
123-
<string>#{v}<\/string>
124-
"
125-
end
126-
def info_version_2 v
127-
" <key>CFBundleVersion</key>
128-
<string>#{v}<\/string>
129-
"
41+
def run_in_page_context(file)
42+
f = File.read(file)
43+
t = File.new(file, 'w')
44+
File.open(WRAPPER) do |w|
45+
w.each_line do |l|
46+
t.write(l.strip == '// insert file here' ? f : l)
47+
end
13048
end
131-
old_v_pattern = ".*"
132-
update_version_in_file (info_version old_v_pattern), (info_version @version), t.name
133-
update_version_in_file (info_version_2 old_v_pattern), (info_version_2 @version), t.name
134-
end
135-
136-
desc 'Increment the version number by 0.0.1, or set a new version'
137-
task :version, [:new_version] => [:update_version, "chrome/src/manifest.json", "safari/src/Info.plist"]
138-
139-
140-
141-
desc 'insert the automatch script into the main extension script'
142-
task :automatch do
143-
insert_automatch_into_main_script
144-
puts 'automatch script inserted into main script'
145-
end
146-
147-
desc 'Use this directory as an "unpacked extension" for developing on Chrome'
148-
task :chrome_dev do
149-
FileUtils.cp_r ['chrome/src/images', 'chrome/src/manifest.json'], '.'
150-
puts 'ready to use this directory as unpacked extension'
151-
end
152-
153-
desc 'Create a .zip file for publishing in the Chrome store'
154-
task :chrome_publish do
155-
insert_set_parser_into_main_script "chrome/src/#{@script}"
156-
FileUtils.rm_rf "chrome/#{@versioned_name}.zip"
157-
sh "cd chrome/src && zip -r ../../build/#{@versioned_name}.zip . && cd -"
158-
puts "build/#{@versioned_name}.zip created and ready to publish"
159-
end
160-
161-
desc 'Create a Safari extension file for development'
162-
task :safari_dev do
163-
tmp_ext_dir = "#{@name}.safariextension"
164-
FileUtils.mkdir_p tmp_ext_dir
165-
insert_set_parser_into_main_script "#{tmp_ext_dir}/#{@script}"
166-
FileUtils.cp ['safari/src/Info.plist', 'safari/src/Settings.plist'], tmp_ext_dir
167-
sh 'safari/createAndSign.sh'
168-
FileUtils.rm_rf tmp_ext_dir
169-
FileUtils.mv "#{@name}.safariextz", "build/#{@name}-dev.safariextz"
170-
puts "build/#{@name}-dev.safariextz created"
171-
end
172-
173-
desc 'Create a versioned Safari extension file for publishing'
174-
task :safari_publish => [:safari_dev] do
175-
FileUtils.mv "build/#{@name}-dev.safariextz", "build/#{@versioned_name}.safariextz"
176-
puts "build/#{@name}-dev.safariextz renamed to build/#{@versioned_name}.safariextz"
49+
t.close
17750
end
17851

179-
desc 'Use this directory as an "unpacked extension" for developing on Opera'
180-
task :opera_dev => [:chrome_dev]
52+
Dir.glob('tasks/*.rake').each { |r| import r }
18153

182-
desc 'Create a .zip file for publishing in the Opera store'
183-
task :opera_publish => [:chrome_publish]
54+
desc 'Build packages for all supported browsers'
55+
task :default => ['build:chrome', 'build:firefox', 'build:safari']

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.15.6
1+
2.0

chrome/images/salvager128.png

32.2 KB
Loading

chrome/images/salvager16.png

1.9 KB
Loading

chrome/images/salvager48.png

5.53 KB
Loading

chrome/manifest.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "Goko Salvager",
3+
"description": "Making Goko almost tolerable",
4+
"version": "2.0",
5+
"manifest_version": 2,
6+
7+
"content_scripts": [
8+
{
9+
"js": [
10+
"Goko_Live_Log_Viewer.user.js",
11+
"automatch.js",
12+
"automatchGamePop.js",
13+
"automatchOfferPop.js",
14+
"automatchSeekPop.js",
15+
"gokoHelpers.js"
16+
],
17+
"matches": [
18+
"http://play.goko.com/Dominion/gameClient.html",
19+
"https://play.goko.com/Dominion/gameClient.html",
20+
"http://beta.goko.com/Dominion/gameClient.html",
21+
"https://beta.goko.com/Dominion/gameClient.html"
22+
]
23+
}
24+
],
25+
26+
"permissions": [
27+
"https://dominion.goko.com/",
28+
"http://dominion.goko.com/",
29+
"https://beta.goko.com/",
30+
"http://beta.goko.com/"
31+
],
32+
33+
"icons": {
34+
"16": "images/salvager16.png",
35+
"48": "images/salvager48.png",
36+
"128": "images/salvager128.png"
37+
}
38+
39+
}

chrome/src/images/icon128.png

-4.28 KB
Binary file not shown.

0 commit comments

Comments
 (0)