forked from webtaculars/Universal-Bypass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.firefox_build.php
75 lines (73 loc) · 1.83 KB
/
.firefox_build.php
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
<?php
if(file_exists("Universal Bypass for Netscape Navigator.zip"))
{
unlink("Universal Bypass for Netscape Navigator.zip");
}
echo "Indexing...\n";
$index = [];
function recursivelyIndex($dir)
{
global $index;
foreach(scandir($dir) as $f)
{
if(substr($f, 0, 1) != ".")
{
$fn = $dir."/".$f;
if(is_dir($fn))
{
recursivelyIndex($fn);
}
else
{
array_push($index, substr($fn, 2));
}
}
}
}
recursivelyIndex(".");
echo "Building...\n";
function createZip($file)
{
$zip = new ZipArchive();
$zip->open($file, ZipArchive::CREATE + ZipArchive::EXCL + ZipArchive::CHECKCONS) or die("Failed to create {$file}.\n");
return $zip;
}
$build = createZip("Universal Bypass for Netscape Navigator.zip");
$build_id = intval(file_get_contents(".next_build_id.txt"));
$json = json_decode(file_get_contents("manifest.json"), true);
$extension_version = $json["version"];
$definitions_version = substr(shell_exec("git rev-parse HEAD"), 0, 7);
foreach($index as $fn)
{
if($fn == "README.md" || $fn == "Universal Bypass for Chromium-based browsers.zip")
{
continue;
}
if($fn == "manifest.json")
{
$json = json_decode(file_get_contents($fn), true);
$json["version"] .= ".".$build_id;
$content = str_replace(" ", "\t", json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
$build->addFromString($fn, $content);
}
else if($fn == "background.js")
{
$content = str_replace([
"extension_version=brws.runtime.getManifest().version,",
"definitions_version=\"\",",
"if(definitions_version===\"\")",
],
[
"extension_version=\"{$extension_version}\",",
"definitions_version=\"{$definitions_version}\",",
"if(false)"
], file_get_contents($fn));
$build->addFromString($fn, $content);
}
else
{
$build->addFile($fn, $fn);
}
}
$build->close();
file_put_contents(".next_build_id.txt", $build_id + 1);