Compatible with Arc browser

This commit is contained in:
suziwen 2024-05-24 19:03:49 +08:00
parent 815e162640
commit 962bc129cd
16 changed files with 2844 additions and 19 deletions

View File

@ -1,7 +1,7 @@
{ {
"manifest_version": 3, "manifest_version": 3,
"name": "ZeroOmega--Proxy Switchy manifest v3 version", "name": "ZeroOmega--Proxy Switchy manifest v3 version",
"version": "3.2.1", "version": "3.2.2",
"description": "__MSG_manifest_app_description__", "description": "__MSG_manifest_app_description__",
"icons": { "icons": {
"16": "img/icons/omega-action-16.png", "16": "img/icons/omega-action-16.png",

View File

@ -1,7 +1,7 @@
{ {
"manifest_version": 3, "manifest_version": 3,
"name": "ZeroOmega--Proxy Switchy manifest v3 version", "name": "ZeroOmega--Proxy Switchy manifest v3 version",
"version": "3.2.1", "version": "3.2.2",
"description": "__MSG_manifest_app_description__", "description": "__MSG_manifest_app_description__",
"icons": { "icons": {
"16": "img/icons/omega-action-16.png", "16": "img/icons/omega-action-16.png",
@ -20,7 +20,7 @@
"32": "img/icons/omega-action-32.png" "32": "img/icons/omega-action-32.png"
}, },
"default_title": "__MSG_manifest_icon_default_title__", "default_title": "__MSG_manifest_icon_default_title__",
"default_popup": "popup/index.html" "default_popup": "popup-iframe.html"
}, },
"background": { "background": {
"service_worker": "x-background.js", "service_worker": "x-background.js",

View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script src="./lib/iframeResizer/iframeResizer.min.js"></script>
<style>
html,body{
margin: 0;
padding:0;
}
iframe {
min-width: 300px;
}
</style>
</head>
<body>
<iframe id="myIframe" src="./popup/index.html" frameborder="0"></iframe>
<script src="./lib/script.js/script.min.js"></script>
<script src="./popup-iframe.js"></script>
</body>
</html>

View File

@ -0,0 +1,14 @@
document.location.href = './popup/index.html'
// arc browser can't use location.href to change.
// https://github.com/suziwen/ZeroOmega/issues/4
$script('js/omega_target_popup.js', 'om-target', function() {
$script('popup/js/style.js', 'om-style')
iFrameResize({
sizeWidth: true,
autoResize: true,
resizeFrom: 'child',
heightCalculationMethod: 'bodyScroll',
widthCalculationMethod: 'bodyOffset'
}, '#myIframe')
})

View File

@ -22,7 +22,8 @@ module.exports = class ExternalApi
return unless @disabled return unless @disabled
@options.setProxyNotControllable(null) @options.setProxyNotControllable(null)
chrome.action.setPopup?({popup: 'popup/index.html'}) #chrome.action.setPopup?({popup: 'popup/index.html'})
chrome.action.setPopup?({popup: 'popup-iframe.html'})
@options.reloadQuickSwitch() @options.reloadQuickSwitch()
@disabled = false @disabled = false
@options.clearBadge() @options.clearBadge()
@ -49,7 +50,8 @@ module.exports = class ExternalApi
if @knownExts[port.sender.id] >= 32 if @knownExts[port.sender.id] >= 32
reason = 'upgrade' reason = 'upgrade'
@options.setProxyNotControllable reason, {text: 'X', color: '#5ab432'} @options.setProxyNotControllable reason, {text: 'X', color: '#5ab432'}
chrome.action.setPopup?({popup: 'popup/index.html'}) #chrome.action.setPopup?({popup: 'popup/index.html'})
chrome.action.setPopup?({popup: 'popup-iframe.html'})
port.postMessage({action: 'state', state: 'disabled'}) port.postMessage({action: 'state', state: 'disabled'})
when 'enable' when 'enable'
@reenable() @reenable()

View File

@ -169,7 +169,8 @@ class ChromeOptions extends OmegaTarget.Options
if quickSwitch if quickSwitch
chrome.action.setPopup({popup: ''}) chrome.action.setPopup({popup: ''})
else else
chrome.action.setPopup({popup: 'popup/index.html'}) #chrome.action.setPopup({popup: 'popup/index.html'})
chrome.action.setPopup({popup: 'popup-iframe.html'})
chrome.contextMenus?.update('enableQuickSwitch', {checked: !!quickSwitch}) chrome.contextMenus?.update('enableQuickSwitch', {checked: !!quickSwitch})
Promise.resolve() Promise.resolve()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -186,6 +186,7 @@ fieldset[disabled] .form-control {
inset: 0; inset: 0;
opacity: 0.1; opacity: 0.1;
background-color: var(--primaryColor); background-color: var(--primaryColor);
pointer-events: none;
} }
.alert-danger { .alert-danger {
@ -386,13 +387,24 @@ main .page-header {
background-color: var(--lighterBackground); background-color: var(--lighterBackground);
} }
.om-nav-item.om-active > a { .om-nav-item.om-active > a {
color: var(--whiteColor); color: var(--whiteColor)!important;
background-color: var(--infoColor); background-color: var(--infoColor);
} }
.om-divider { .om-divider {
background-color: var(--lighterBackground); background-color: var(--lighterBackground);
} }
.om-edit-toggle{
background-color: var(--defaultBackground);
border-color: var(--selectionBackground);
color: var(--primaryColor);
}
.om-edit-toggle:hover{
background-color: var(--lighterBackground);
border-color: var(--highlightBackground);
}
/** /**
* spectrum.css * spectrum.css
**/ **/

View File

@ -87,19 +87,19 @@ module.controller 'PopupCtrl', ($scope, $window, $q, omegaTarget,
$scope.customCss = customCss $scope.customCss = customCss
$scope.closePopup = -> $scope.closePopup = ->
$window.close() $window.top.close()
$scope.openManage = -> $scope.openManage = ->
omegaTarget.openManage() omegaTarget.openManage()
$window.close() $window.top.close()
refreshOnProfileChange = false refreshOnProfileChange = false
refresh = -> refresh = ->
if refreshOnProfileChange if refreshOnProfileChange
omegaTarget.refreshActivePage().then -> omegaTarget.refreshActivePage().then ->
$window.close() $window.top.close()
else else
$window.close() $window.top.close()
$scope.profileIcons = profileIcons $scope.profileIcons = profileIcons
$scope.dispNameFilter = dispNameFilter $scope.dispNameFilter = dispNameFilter
$scope.isActive = (profileName) -> $scope.isActive = (profileName) ->
@ -123,7 +123,7 @@ module.controller 'PopupCtrl', ($scope, $window, $q, omegaTarget,
desc || profile?.name || '' desc || profile?.name || ''
$scope.openOptions = (hash) -> $scope.openOptions = (hash) ->
omegaTarget.openOptions(hash).then -> omegaTarget.openOptions(hash).then ->
$window.close() $window.top.close()
$scope.openConditionHelp = -> $scope.openConditionHelp = ->
pname = encodeURIComponent($scope.currentProfileName) pname = encodeURIComponent($scope.currentProfileName)
$scope.openOptions("#/profile/#{pname}?help=condition") $scope.openOptions("#/profile/#{pname}?help=condition")
@ -143,9 +143,9 @@ module.controller 'PopupCtrl', ($scope, $window, $q, omegaTarget,
).then(next) ).then(next)
if apply if apply
apply.then -> $window.close() apply.then -> $window.top.close()
else else
$window.close() $window.top.close()
$scope.tempRuleMenu = {open: false} $scope.tempRuleMenu = {open: false}
$scope.nameExternal = {open: false} $scope.nameExternal = {open: false}

View File

@ -4,8 +4,9 @@
body { body {
margin: 0; margin: 0;
padding: 0; padding: 10px;
min-width: 180px; min-width: 180px;
width: fit-content;
} }
body.with-condition-form { body.with-condition-form {

View File

@ -158,6 +158,7 @@ html(lang='en' ng-app='omegaPopup' ng-controller='PopupCtrl' ng-csp)
ng-click='openOptions("#/general")') {{'popup_configureMonitorWebRequests' | tr}} ng-click='openOptions("#/general")') {{'popup_configureMonitorWebRequests' | tr}}
script(src='js/log_error.js') script(src='js/log_error.js')
script(src='lib/iframeResizer/iframeResizer.contentWindow.min.js')
script(src='lib/jquery/jquery.min.js') script(src='lib/jquery/jquery.min.js')
script(src='lib/angular/angular.min.js') script(src='lib/angular/angular.min.js')
script(src='lib/angular-bootstrap/ui-bootstrap-tpls.min.js') script(src='lib/angular-bootstrap/ui-bootstrap-tpls.min.js')

View File

@ -17,7 +17,7 @@ html, body {
body { body {
min-width: 12em; min-width: 12em;
margin: 5px; padding: 5px 0;
} }
.om-hidden { .om-hidden {
@ -33,7 +33,7 @@ body {
.om-nav { .om-nav {
list-style: none; list-style: none;
padding: 0; padding: 0;
margin: 0; margin: 5px;
} }
.om-nav-item { .om-nav-item {

View File

@ -51,6 +51,7 @@
</a> </a>
</li> </li>
</ul> </ul>
<script src="../../lib/iframeResizer/iframeResizer.contentWindow.min.js"></script>
<script src="../../lib/script.js/script.min.js"></script> <script src="../../lib/script.js/script.min.js"></script>
<script src="js/loader.js"></script> <script src="js/loader.js"></script>
</body> </body>

View File

@ -13,7 +13,7 @@
} }
function closePopup() { function closePopup() {
window.close(); window.top.close();
// If the popup is opened as a tab, the above won't work. Let's reload then. // If the popup is opened as a tab, the above won't work. Let's reload then.
document.body.style.opacity = 0; document.body.style.opacity = 0;
setTimeout(function() { history.go(0); }, 300); setTimeout(function() { history.go(0); }, 300);

View File

@ -1,6 +1,6 @@
(function() { (function() {
function closePopup() { function closePopup() {
window.close(); window.top.close();
// If the popup is opened as a tab, the above won't work. Let's reload then. // If the popup is opened as a tab, the above won't work. Let's reload then.
document.body.style.opacity = 0; document.body.style.opacity = 0;
setTimeout(function() { history.go(0); }, 300); setTimeout(function() { history.go(0); }, 300);