Skip to content

Commit

Permalink
1.0.1 PWA
Browse files Browse the repository at this point in the history
  • Loading branch information
Dituon committed Jun 11, 2023
1 parent e140f85 commit 525fa49
Show file tree
Hide file tree
Showing 10 changed files with 8,063 additions and 736 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ index.html

.idea/
manifest.json
workbox-*.js
sw.js
manifest.webmanifest
31 changes: 26 additions & 5 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<meta name="apple-mobile-web-app-title" content="Grasscutter Command Helper">

<title bind="title">Grasscutter Command Helper</title>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-6954577391022234"
crossorigin="anonymous"></script>
</head>

<body>
Expand Down Expand Up @@ -65,6 +67,8 @@ <h2 bind="output-result">
<div id="command-push" bind="command-push">📦 Push To Worktop</div>
</div>
</div>
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6954577391022234"
data-ad-slot="1757983692" data-ad-format="auto" data-full-width-responsive="true"></ins>
<div class="bottom links" bind="links">
<a href="https://github.com/Dituon/grasscutter-command-helper">❤Github❤</a>
<a href="https://discord.gg/uDSQfQTrd8">✨Discord✨</a>
Expand Down Expand Up @@ -183,6 +187,9 @@ <h3 bind="export-setting">💡 Export Setting</h3>
</div>
</div>

<div class="button-group">
<div bind="install-app" id="install-app">📲 Install App</div>
</div>
<div class="button-group">
<div bind="clear-cache" id="clear-cache">⚠ Clear Cache</div>
</div>
Expand All @@ -209,14 +216,28 @@ <h3 bind="share-raw">Raw Data</h3>

<script type="module" src="./module/app/app.js"></script>
<script>
var _hmt = _hmt || [];
(function () {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?129cb40fd9462f1042b3326cd7c145cc";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<script>
const localStorageKey = 'showAdsTime'
const probability = 0.2;

(function showAds(show = true) {
const date = new Date().getDate()

if ("serviceWorker" in navigator) {
window.addEventListener("load", function () {
navigator.serviceWorker.register("./sw.js");
})
}
if (!show && localStorage.getItem(localStorageKey) === date.toString()) return

localStorage.setItem(localStorageKey, date.toString());
(adsbygoogle = window.adsbygoogle || []).push({})
})(Math.random() <= probability)
</script>

</body>

</html>
1 change: 0 additions & 1 deletion src/module/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import '../remote'
import '../share'

import './app.css'
import '../utils/ads.js'

import { loadUrlParam } from './url-param'
loadUrlParam()
10 changes: 10 additions & 0 deletions src/module/app/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ authorInputElement.addEventListener('change', e => {
config.author = e.target.value
})

const installAppBtn = document.getElementById('install-app')
window.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault()
deferredPrompt = e

installAppBtn.addEventListener('click', e => {
deferredPrompt.prompt()
})
})

const clearCacheBtn = document.getElementById('clear-cache')
clearCacheBtn.addEventListener('click', e => {
localStorage.clear()
Expand Down
2 changes: 1 addition & 1 deletion src/module/share/worktop.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { menu } from "../command/command-menu.js"
import { CommandGroup } from "../command/command-parser.js"
import { Icon, showMessage, SideBar } from "../ui/ui.js"
import { server, execCommand } from "../remote/remote-execute.js"
import { execCommand } from "../remote/remote-execute.js"
import { langData } from "../app/lang-loader.js"

import './worktop.css'
Expand Down
13 changes: 0 additions & 13 deletions src/module/utils/ads.js

This file was deleted.

Loading

0 comments on commit 525fa49

Please sign in to comment.