firefox-hash-generator 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +23 -0
- data/README.md +54 -0
- data/lib/firefox_hash_generator.rb +36 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ae346bc8c98ba04ffa83b921a8968f2614704173937233623b0d0b35590e0877
|
4
|
+
data.tar.gz: e7b96414f78b7cdd1423fb44937b946bcdcfc2c12dbd519cea45043a3677a6c7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ddb78b81e2aa24c8fb50c3bdbfc7e7aa80a26d1742d20e9fef0d26693318f7faa6cb1de391201f380c2172d0f425f01af067a7d55e1dff153b692868e254cc1d
|
7
|
+
data.tar.gz: '091e33d0d376f0eba1a5c0dbc9e8888aeb6fb8dea691bfa07ba2605e82d23a8d68e9407a4ee0fabc4ecf4bd1f8782ac7045f5147d2211f4e4daa8bbabe8a0493'
|
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
=====================
|
3
|
+
|
4
|
+
Copyright (c) 2021 Oleg Pudeyev
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
20
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
21
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
22
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
23
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Firefox/Waterfox/Pale Moon Hash Generator
|
2
|
+
|
3
|
+
This library generates the hashes for firefox and derived browsers' search
|
4
|
+
engine file. The hash is needed to programmatically set the default search
|
5
|
+
engine.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
require 'firefox_hash_generator'
|
10
|
+
|
11
|
+
FirefoxHashGenerator.generate(
|
12
|
+
:firefox,
|
13
|
+
'randombytes.default',
|
14
|
+
'DuckDuckGo',
|
15
|
+
)
|
16
|
+
|
17
|
+
The first argument is the browser app name. This can be retrieved from the
|
18
|
+
[browser console](https://developer.mozilla.org/en-US/docs/Tools/Browser_Console)
|
19
|
+
by typing `Services.appinfo.name` for your browser. Note that the input
|
20
|
+
control is disabled by default and is enabled by setting the `about:config`
|
21
|
+
pref `devtools.chrome.enabled` to `true`.
|
22
|
+
|
23
|
+
The app name can be provided as a string or, for convenience, a symbol that
|
24
|
+
maps the known browsers to their app names. Currently the following browsers
|
25
|
+
are known:
|
26
|
+
|
27
|
+
- `:firefox`
|
28
|
+
- `:pale_moon`
|
29
|
+
- `:waterfox`
|
30
|
+
|
31
|
+
The second parameter is the basename of the profile directory. It usually
|
32
|
+
consists of a randomly generated string followed by the profile name.
|
33
|
+
|
34
|
+
The third parameter is the name of the search engine that is being set as the
|
35
|
+
default one.
|
36
|
+
|
37
|
+
The entire process was copied from [this](https://blog.onee3.org/2018/04/manually-add-a-search-engine-to-firefox-quantum/)
|
38
|
+
amazing guide by Frederick Zhang.
|
39
|
+
|
40
|
+
To extract the JSON serialization of the search engine configuration from the
|
41
|
+
`search.json.mozlz4` file (which contains a proprietary header followed by
|
42
|
+
the LZ4-compressed JSON), use a utility like [lz4jsoncat](https://github.com/andikleen/lz4json)
|
43
|
+
or [this Python code](https://gist.github.com/kaefer3000/73febe1eec898cd50ce4de1af79a332a)
|
44
|
+
(which originated from [this Python code](https://gist.github.com/Tblue/62ff47bef7f894e92ed5)).
|
45
|
+
For Ruby, a working LZ4 compressor/decompressor is
|
46
|
+
[extlz4](https://github.com/dearblue/ruby-extlz4).
|
47
|
+
|
48
|
+
## Bugs & Patches
|
49
|
+
|
50
|
+
Please report via issues and pull requests.
|
51
|
+
|
52
|
+
## License
|
53
|
+
|
54
|
+
MIT
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'digest'
|
2
|
+
|
3
|
+
module FirefoxHashGenerator
|
4
|
+
class UnknownAppName < StandardError; end
|
5
|
+
|
6
|
+
# @see https://blog.onee3.org/2018/04/manually-add-a-search-engine-to-firefox-quantum/
|
7
|
+
# @see https://developer.mozilla.org/en-US/docs/Tools/Browser_Console
|
8
|
+
# @see https://hg.mozilla.org/mozilla-central/rev/2ae760290f8c
|
9
|
+
module_function def generate(app_name, profile_basename, search_engine_name)
|
10
|
+
if app_name.is_a?(Symbol)
|
11
|
+
begin
|
12
|
+
app_name = APP_NAMES.fetch(app_name)
|
13
|
+
rescue KeyError
|
14
|
+
raise UnknownAppName, "The app name symbol #{app_name.inspect} is not known - either add it to the APP_NAMES constant or specify a string name"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
text = profile_basename + search_engine_name + TEMPLATE.gsub('$appName', app_name)
|
19
|
+
Digest::SHA256.base64digest(text)
|
20
|
+
end
|
21
|
+
|
22
|
+
APP_NAMES = {
|
23
|
+
firefox: 'Firefox',
|
24
|
+
pale_moon: 'Pale Moon',
|
25
|
+
waterfox: 'Waterfox',
|
26
|
+
}.freeze
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
TEMPLATE = "By modifying this file, I agree that I am doing so " +
|
31
|
+
"only within $appName itself, using official, user-driven search " +
|
32
|
+
"engine selection processes, and in a way which does not circumvent " +
|
33
|
+
"user consent. I acknowledge that any attempt to change this file " +
|
34
|
+
"from outside of $appName is a malicious act, and will be responded " +
|
35
|
+
"to accordingly.".freeze
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: firefox-hash-generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Oleg Pudeyev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-07-07 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Firefox/Waterfox/Pale Moon search engine hash generator
|
14
|
+
email: code@olegp.name
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- LICENSE
|
20
|
+
- README.md
|
21
|
+
- lib/firefox_hash_generator.rb
|
22
|
+
homepage: https://github.com/p/firefox-hash-generator
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options:
|
28
|
+
- "--charset=UTF-8"
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubygems_version: 3.2.5
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: firefox-hash-generator-1.0.0
|
46
|
+
test_files: []
|