Self-host Universal Bypass for Firefox

This commit is contained in:
Tim "timmyRS" Speckhals 2020-04-07 19:36:50 +02:00
parent c78b9d7cad
commit bbe67a73d5
6 changed files with 109 additions and 14 deletions

View File

@ -1,11 +1,41 @@
<?php
if(file_exists("Universal Bypass.zip"))
function recursivelyDelete($path)
{
unlink("Universal Bypass.zip");
if(substr($path, -1) == "/")
{
$path = substr($path, 0, -1);
}
if(!file_exists($path))
{
return;
}
if(is_dir($path))
{
foreach(scandir($path) as $file)
{
if(!in_array($file, [
".",
".."
]))
{
recursivelyDelete($path."/".$file);
}
}
rmdir($path);
}
else
{
unlink($path);
}
}
if(file_exists("Universal Bypass for Firefox.zip"))
if(is_file("Universal Bypass for Chromium-based browsers.zip"))
{
unlink("Universal Bypass for Firefox.zip");
unlink("Universal Bypass for Chromium-based browsers.zip");
}
if(is_dir(".firefox"))
{
recursivelyDelete(".firefox");
}
echo "Indexing...\n";
@ -20,6 +50,7 @@ function recursivelyIndex($dir)
$fn = $dir."/".$f;
if(is_dir($fn))
{
mkdir(".firefox/".$fn);
recursivelyIndex($fn);
}
else
@ -29,6 +60,7 @@ function recursivelyIndex($dir)
}
}
}
mkdir(".firefox");
recursivelyIndex(".");
echo "Building...\n";
@ -38,11 +70,10 @@ function createZip($file)
$zip->open($file, ZipArchive::CREATE + ZipArchive::EXCL + ZipArchive::CHECKCONS) or die("Failed to create {$file}.\n");
return $zip;
}
$raw_build = createZip("Universal Bypass for Firefox.zip");
$chromium_build = createZip("Universal Bypass for Chromium-based browsers.zip");
$build = createZip("Universal Bypass for Chromium-based browsers.zip");
foreach($index as $fn)
{
if($fn == "README.md" || $fn == "Universal Bypass for Firefox.zip" || $fn == "injection_script.js" || $fn == "rules.json")
if($fn == "README.md" || $fn == "injection_script.js" || $fn == "rules.json")
{
continue;
}
@ -51,13 +82,14 @@ foreach($index as $fn)
$json = json_decode(file_get_contents($fn), true);
unset($json["browser_specific_settings"]);
$json["incognito"] = "split";
$chromium_build->addFromString($fn, json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
$build->addFromString($fn, json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
else
{
$chromium_build->addFile($fn, $fn);
$build->addFile($fn, $fn);
}
$raw_build->addFile($fn, $fn);
copy($fn, ".firefox/".$fn);
}
$raw_build->close();
$chromium_build->close();
$build->close();
passthru(".firefox_build.bat");
recursivelyDelete(".firefox");

57
.chromium_build.php Normal file
View File

@ -0,0 +1,57 @@
<?php
if(file_exists("Universal Bypass for Chromium-based browsers.zip"))
{
unlink("Universal Bypass for Chromium-based browsers.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 Chromium-based browsers.zip");
foreach($index as $fn)
{
if($fn == "README.md" || $fn == "injection_script.js" || $fn == "rules.json")
{
continue;
}
if($fn == "manifest.json")
{
$json = json_decode(file_get_contents($fn), true);
$json["browser_specific_settings"]["gecko"]["update_url"] = "https://universal-bypass.org/firefox-will-never-overtake-chromium/updates.json";
unset($json["browser_specific_settings"]);
$json["incognito"] = "split";
$build->addFromString($fn, json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
else
{
$build->addFile($fn, $fn);
}
}
$build->close();

View File

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.firefox_build.bat

View File

@ -661,6 +661,10 @@ ensureDomLoaded(()=>{
document.querySelectorAll("form[action]").forEach(e=>e.action+="#ignoreCrowdBypass")
document.querySelectorAll("a[href]").forEach(e=>e.href+="#ignoreCrowdBypass")
}
if(typeof InstallTrigger=="object"&&UNIVERSAL_BYPASS_EXTERNAL_VERSION!="13.9")
{
insertInfoBox("Universal Bypass for Firefox is now self-hosted. You will no longer get updates unless you re-install it.")
}
domainBypass("up-load.io",()=>{
if(UNIVERSAL_BYPASS_INTERNAL_VERSION>=7)
{

View File

@ -11,7 +11,7 @@
"name": "Universal Bypass",
"description": "__MSG_appDesc__",
"homepage_url": "https://universal-bypass.org/",
"version": "13.9.0",
"version": "13.9",
"author": "Tim \"timmyRS\" Speckhals",
"permissions": [
"alarms",
@ -46,7 +46,8 @@
],
"browser_specific_settings": {
"gecko": {
"id": "{529b261b-df0b-4e3b-bf42-07b462da0ee8}"
"id": "{8f4fa810-9c36-4b81-8e72-de97c8f29d67}",
"update_url": "https://universal-bypass.org/firefox-will-never-overtake-chromium/updates.json"
}
},
"web_accessible_resources": [