Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
add darkmode / popup page
Browse files Browse the repository at this point in the history
  • Loading branch information
jiacai2050 committed Sep 12, 2020
1 parent 69ef988 commit cfb2f67
Show file tree
Hide file tree
Showing 33 changed files with 299 additions and 164 deletions.
3 changes: 2 additions & 1 deletion cljs-src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ node_modules/
out/
package-lock.json
resources/release/background/main.js
resources/release/option/main.js
resources/release/ui/*js
resources/dev/ui/*js
5 changes: 5 additions & 0 deletions cljs-src/externs/darkreader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var DarkReader = {
enable: function(){},
disable: function(){},
auto: function(){},
}
19 changes: 19 additions & 0 deletions cljs-src/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

cd "$(cd `dirname $0`;pwd)"

set -x

rm resources/release/ui/option.js \
resources/release/ui/popup.js \
resources/release/background/main.js


lein with-profile release do clean, cljsbuild once option
lein with-profile release do clean, cljsbuild once background
lein with-profile release do clean, cljsbuild once popup
# clean compiled js before packaging
lein with-profile release clean

cd resources/release
zip -x *.DS_Store -r ~/gooreplacer_`date +%s`.zip *
194 changes: 104 additions & 90 deletions cljs-src/project.clj
Original file line number Diff line number Diff line change
@@ -1,101 +1,115 @@
(defproject gooreplacer "3.10.0"
:description "Modify, block URLs & Headers"
:url "https://github.com/jiacai2050/gooreplacer"
:license {:name "MIT"
:url "http://liujiacai.net/license/MIT.html?year=2015"}
:dependencies [[org.clojure/clojure "1.10.0"]
[org.clojure/clojurescript "1.10.597"]
[figwheel-sidecar "0.5.14"]
[org.clojure/core.match "0.3.0-alpha5"]
[org.clojure/data.json "0.2.7"]
[alandipert/storage-atom "2.0.1"]
:description "Modify, block URLs & Headers"
:url "https://github.com/jiacai2050/gooreplacer"
:license {:name "MIT"
:url "http://liujiacai.net/license/MIT.html?year=2015"}
:dependencies [[org.clojure/clojure "1.10.1"]
[org.clojure/clojurescript "1.10.773"]
[figwheel-sidecar "0.5.14"]
[org.clojure/core.match "1.0.0"]
[org.clojure/data.json "1.0.0"]
[alandipert/storage-atom "2.0.1"]

;; ui
[antizer "0.3.0"]
[cljs-http "0.1.43"]
[org.clojure/core.async "0.3.443"]
[reagent "0.8.1"]]
:plugins [[lein-figwheel "0.5.14"]
[lein-cljsbuild "1.1.7"]
[lein-doo "0.1.8"]]
:profiles {
;; https://docs.cider.mx/cider/0.23/basics/clojurescript.html#_piggieback
;; cider will jack in piggieback automatically
;; :dev {:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}}
:dev-option {:clean-targets ^{:protect false} [:target-path "resources/dev/option/js"]
:cljsbuild {:builds [{:id "dev"
:figwheel true
:source-paths ["src"]
:compiler {:output-to "resources/dev/option/js/main.js"
:source-map true
:asset-path "js"
:output-dir "resources/dev/option/js"
:optimizations :none
:main gooreplacer.option.core
:verbose true}}]}
:figwheel {:server-port 8080
:http-server-root "dev/option"
:css-dirs ["resources/dev/option/css"]
:server-logfile ".figwheel_option.log"
:repl true}}
:dev-popup {:clean-targets ^{:protect false} [:target-path "resources/dev/popup/js"]
;; ui
[antizer "0.3.0"]
[cljs-http "0.1.46"]
[org.clojure/core.async "1.3.610"]
[reagent "0.10.0"]]
:plugins [[lein-figwheel "0.5.14"]
[lein-cljsbuild "1.1.8"]
[lein-doo "0.1.8"]]
:profiles {
;; https://docs.cider.mx/cider/0.23/basics/clojurescript.html#_piggieback
;; cider will jack in piggieback automatically
;; :dev {:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}}
:dev-option {:clean-targets ^{:protect false} [:target-path "resources/dev/ui/compiled-js/option"]
:cljsbuild {:builds [{:id "dev"
:figwheel true
:compiler {:output-to "resources/dev/popup/js/main.js"
:source-paths ["src"]
:compiler {:output-dir "resources/dev/ui/compiled-js/option"
:source-map true
:asset-path "js"
:output-dir "resources/dev/popup/js"
:output-to "resources/dev/ui/js/option.js"
:optimizations :none
:main gooreplacer.popup.core
:main gooreplacer.option.core
:verbose true}}]}
:figwheel {:server-port 8081
:http-server-root "dev/option"
:css-dirs ["resources/dev/option/css"]
:server-logfile ".figwheel_popup.log"
:figwheel {:server-port 8080
:http-server-root "dev/ui"
:css-dirs ["resources/dev/ui/css"]
:server-logfile ".figwheel_option.log"
:repl true}}
:dev-bg {:clean-targets ^{:protect false} [:target-path "resources/dev/background/js"]
:figwheel {:server-port 8089
:http-server-root "dev/background"
:server-logfile ".figwheel_bg.log"
:repl true}
:cljsbuild {:builds [{:id "dev"
:dev-popup {:clean-targets ^{:protect false} [:target-path "resources/dev/ui/compiled-js/popup"]
:cljsbuild {:builds [{:id "dev"
:figwheel true
:source-paths ["src"]
:compiler {:output-dir "resources/dev/ui/compiled-js/popup"
:source-map true
:asset-path "js"
:output-to "resources/dev/ui/js/pop.js"
:optimizations :none
:main gooreplacer.popup
:verbose true}}]}
:figwheel {:server-port 8090
:http-server-root "dev/ui"
:css-dirs ["resources/dev/ui/css"]
:server-logfile ".figwheel_popup.log"
:repl true}}
:dev-bg {:clean-targets ^{:protect false} [:target-path "resources/dev/background/js"]
:figwheel {:server-port 8095
:http-server-root "dev/background"
:server-logfile ".figwheel_bg.log"
:repl true}
:cljsbuild {:builds [{:id "dev"
:source-paths ["src"]
:figwheel true
:compiler {:output-to "resources/dev/background/js/main.js"
:source-map true
:output-dir "resources/dev/background/js"
:asset-path "js"
:main gooreplacer.background
:optimizations :none
:verbose true}}]}}
:release {:clean-targets ^{:protect false} [:target-path
"resources/release/ui/option-js"
"resources/release/ui/popup-js"
"resources/release/background/js"]
:cljsbuild {:builds [{:id "option"
:source-paths ["src"]
:figwheel true
:compiler {:output-to "resources/dev/background/js/main.js"
:source-map true
:output-dir "resources/dev/background/js"
:asset-path "js"
:main gooreplacer.background
:optimizations :none
:verbose true}}]}}
:release {:clean-targets ^{:protect false} [:target-path
"resources/release/option/js"
"resources/release/background/js"]
:cljsbuild {:builds [{:id "option"
:compiler {:output-to "resources/release/option/main.js"
:output-dir "resources/release/option/js"
:externs ["externs/chrome_extensions.js" "externs/chrome.js"]
:optimizations :advanced
:main gooreplacer.option.core}}
{:id "background"
:compiler {:output-to "resources/release/background/main.js"
:output-dir "resources/release/background/js"
:externs ["externs/chrome_extensions.js" "externs/chrome.js"]
:optimizations :advanced
:main gooreplacer.background}}]}}
:test {:cljsbuild {:builds [{:id "test"
:compiler {:output-to "out/main.js"
:main gooreplacer.runner
:optimizations :none}}]}
:doo {:build "test"}}}
:compiler {:output-to "resources/release/ui/option.js"
:output-dir "resources/release/ui/option-js"
:externs ["externs/chrome_extensions.js" "externs/chrome.js" "externs/darkreader.js"]
:optimizations :advanced
:main gooreplacer.option.core}}
{:id "popup"
:source-paths ["src"]
:compiler {:output-to "resources/release/ui/popup.js"
:output-dir "resources/release/ui/popup-js"
:externs ["externs/chrome_extensions.js" "externs/chrome.js" "externs/darkreader.js"]
:optimizations :advanced
:main gooreplacer.popup}}
{:id "background"
:source-paths ["src"]
:compiler {:output-to "resources/release/background/main.js"
:output-dir "resources/release/background/js"
:externs ["externs/chrome_extensions.js" "externs/chrome.js"]
:optimizations :advanced
:main gooreplacer.background}}]}}
:test {:cljsbuild {:builds [{:id "test"
:compiler {:output-to "out/main.js"
:main gooreplacer.runner
:optimizations :none}}]}
:doo {:build "test"}}}

:aliases {"option" ["with-profile" "dev-option" "do"
["clean"]
["figwheel" "dev"]]
"bg" ["with-profile" "dev-bg" "do"
["clean"]
["figwheel" "dev"]]
"test-and-watch" ["with-profile" "test" "do"
["clean"]
;; First install phantom
["doo" "phantom"]]})
:aliases {"option" ["with-profile" "dev-option" "do"
["clean"]
["figwheel" "dev"]]
"popup"["with-profile" "dev-popup" "do"
["clean"]
["figwheel" "dev"]]
"bg" ["with-profile" "dev-bg" "do"
["clean"]
["figwheel" "dev"]]
"test-and-watch" ["with-profile" "test" "do"
["clean"]
;; First install phantom
["doo" "phantom"]]})
14 changes: 0 additions & 14 deletions cljs-src/release.sh

This file was deleted.

5 changes: 5 additions & 0 deletions cljs-src/resources/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,10 @@
}
},
"titleGlobalSwitch": {"message" : "Master Switch"},
"titleTheme": {"message" : "Theme"},
"titleDark": {"message" : "Dark"},
"titleLight": {"message" : "Light"},
"titleAuto": {"message" : "Auto"},
"titleConfigRule": {"message" : "Config Rules"},
"tabSetting": {"message" : "Settings" }
}
5 changes: 5 additions & 0 deletions cljs-src/resources/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,10 @@
}
},
"titleGlobalSwitch": {"message" : "全局开关"},
"titleTheme": {"message" : "主题"},
"titleDark": {"message" : ""},
"titleLight": {"message" : ""},
"titleAuto": {"message" : "跟随系统"},
"titleConfigRule": {"message" : "配置规则"},
"tabSetting": {"message" : "设置" }
}
6 changes: 3 additions & 3 deletions cljs-src/resources/config/db.edn
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
{:name :request-headers
:init-value []}
{:name :response-headers
:init-value []}]


:init-value []}
{:name :theme
:init-value "auto"}]
2 changes: 1 addition & 1 deletion cljs-src/resources/dev/background/init.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
goog.require("figwheel.connect.build_dev");
goog.require("gooreplacer.core");
goog.require("gooreplacer.background");
1 change: 0 additions & 1 deletion cljs-src/resources/dev/option/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions cljs-src/resources/dev/popup/index.html

This file was deleted.

File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions cljs-src/resources/dev/ui/init-popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
goog.require("figwheel.connect.build_dev");
goog.require("gooreplacer.popup");
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="img/gooreplacer.ico" type="image/x-icon">
<link rel="icon" href="img/gooreplacer.ico" type="image/x-icon">
<link rel="shortcut icon" href="img/32.png" type="image/x-icon">
<link rel="icon" href="img/32.png" type="image/x-icon">
<meta charset="utf-8">
<!-- https://github.com/facebook/react/tree/master/packages/react-devtools#usage-with-react-dom -->
<script src="http://localhost:8097"></script>
<script type="text/javascript" src="js/goog/base.js"></script>
<script type="text/javascript" src="js/cljs_deps.js"></script>
<link rel="stylesheet" type="text/css" href="css/main.css">
<script type="text/javascript" src="compiled-js/option/goog/base.js"></script>
<script type="text/javascript" src="compiled-js/option/cljs_deps.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/antd.min.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/darkreader.min.js"></script>
<meta charset="UTF-8">
<title>Gooreplacer</title>
</head>
<body>
<div id="app"></div>
<script type="text/javascript" src="init.js"></script>
<script type="text/javascript" src="init-option.js"></script>
<input type="file" id="gsonChooser" accept=".gson" style="display:none" />
</body>
</html>
21 changes: 21 additions & 0 deletions cljs-src/resources/dev/ui/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="img/32.png" type="image/x-icon">
<link rel="icon" href="img/32.png" type="image/x-icon">
<meta charset="utf-8">
<!-- https://github.com/facebook/react/tree/master/packages/react-devtools#usage-with-react-dom -->
<script src="http://localhost:8097"></script>
<script type="text/javascript" src="compiled-js/popup/goog/base.js"></script>
<script type="text/javascript" src="compiled-js/popup/cljs_deps.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/darkreader.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/antd.min.css">
<meta charset="UTF-8">
<title>Gooreplacer</title>
</head>
<body>
<div id="popup-div"></div>
<script type="text/javascript" src="init-popup.js"></script>
</body>
</html>
Binary file added cljs-src/resources/img/16-off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added cljs-src/resources/img/32-off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added cljs-src/resources/img/48-off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed cljs-src/resources/img/gooreplacer.ico
Binary file not shown.
19 changes: 10 additions & 9 deletions cljs-src/resources/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,26 @@
"page": "background/index.html"
},
"icons": {
"32": "option/img/32.png",
"16": "option/img/16.png",
"48": "option/img/48.png"
"32": "ui/img/32.png",
"16": "ui/img/16.png",
"48": "ui/img/48.png"
},
"browser_action": {
"default_icon": {
"32": "option/img/32.png",
"16": "option/img/16.png",
"48": "option/img/48.png"
"32": "ui/img/32.png",
"16": "ui/img/16.png",
"48": "ui/img/48.png"
},
"default_title": "Modify, block URLs & Headers"
"default_title": "Modify, block URLs & Headers",
"default_popup": "ui/popup.html"
},
"options_ui": {
"page": "option/index.html",
"page": "ui/option.html",
"chrome_style": false,
"open_in_tab": true
},
"author": "http://liujiacai.net",
"homepage_url": "https://github.com/jiacai2050/gooreplacer",
"content_security_policy": "default-src 'unsafe-eval' 'self' http://localhost:8097; style-src http://* https://* 'unsafe-inline' 'unsafe-eval'; connect-src http://* http://localhost:* ws://localhost:* ; font-src https://*",
"content_security_policy": "default-src 'unsafe-eval' 'self' https://cdn.jsdelivr.net http://localhost:8097; style-src http://* https://* 'unsafe-inline' 'unsafe-eval'; connect-src http://* http://localhost:* ws://localhost:* ; font-src https://*; img-src 'self' data:",
"manifest_version": 2
}
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit cfb2f67

Please sign in to comment.