Skip to content

Commit

Permalink
Removed UA Detection
Browse files Browse the repository at this point in the history
  • Loading branch information
xbubbo authored Mar 14, 2024
1 parent 00b2dc0 commit d98c8fb
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 53 deletions.
2 changes: 1 addition & 1 deletion static/assets/scripts/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
window.addEventListener('load', () => {
navigator.serviceWorker.register('../sw.js?v=1', {
navigator.serviceWorker.register('../sw.js?v=2', {
scope: '/a/',
})
})
Expand Down
12 changes: 0 additions & 12 deletions static/assets/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@ document.addEventListener('DOMContentLoaded', function () {
}
}
})
// UA Detection
const isiPhone = /iPhone/i.test(navigator.userAgent)
const isiPad = /iPad/i.test(navigator.userAgent)

if (isiPhone || isiPad) {
if (typeof localStorage !== 'undefined') {
localStorage.setItem('dy', 'auto')
} else {
console.error('localStorage is not available.')
}
}

// Themes
var themeid = localStorage.getItem('theme')
themeEle = document.createElement('link')
Expand Down
6 changes: 3 additions & 3 deletions static/dy/client.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/dy/client.js.map

Large diffs are not rendered by default.

26 changes: 4 additions & 22 deletions static/dy/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
const isAndroid = () => /Android/i.test(navigator.userAgent);
const isiPhone = () => /iPhone/i.test(navigator.userAgent);
const isiPad = () => /iPad/i.test(navigator.userAgent);

self.__dynamic$config = {
prefix: '/a/q/',
encoding: 'xor',
Expand All @@ -14,11 +10,7 @@ self.__dynamic$config = {
tab: {
title: null,
icon: null,
ua: isAndroid()
? 'Mozilla/5.0 (Linux; Android 10; Mobile; rv:68.0) Gecko/68.0 Firefox/68.0'
: isiPad()
? 'Mozilla/5.0 (iPad; CPU OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Safari/604.1'
: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
ua: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.3'
},
assets: {
prefix: '/dy/',
Expand All @@ -27,18 +19,8 @@ self.__dynamic$config = {
client: 'client.js',
worker: 'worker.js',
config: 'config.js',
inject: function () {
navigator.__defineGetter__('userAgent', () =>
isiPhone()
? 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1'
: isiPad()
? 'Mozilla/5.0 (iPad; CPU OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Safari/604.1'
: isAndroid()
? 'Mozilla/5.0 (Linux; Android 10; Mobile; rv:68.0) Gecko/68.0 Firefox/68.0'
: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36'
);
},
},
inject: ''
}
},
block: [],
block: []
};
8 changes: 4 additions & 4 deletions static/dy/handler.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/dy/handler.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions static/dy/worker.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/dy/worker.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/m/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ self.__uv$config = {
handler: '/m/handler.js',
bundle: '/m/bundle.js',
config: '/m/config.js',
sw: '/m/sw.js?v=1',
sw: '/m/sw.js?v=2',
};
4 changes: 2 additions & 2 deletions static/sw.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
importScripts('/dy/config.js?v=2')
importScripts('/dy/config.js?v=3')
importScripts('/dy/worker.js')
importScripts('/m/bundle.js')
importScripts('/m/config.js')
importScripts(__uv$config.sw || '/m/sw.js')
importScripts(__uv$config.sw || '/m/sw.js?v=2')

const uv = new UVServiceWorker()
const dynamic = new Dynamic()
Expand Down
2 changes: 1 addition & 1 deletion static/tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</div>
<script>
window.addEventListener('load', () => {
navigator.serviceWorker.register('../sw.js?v=1', {
navigator.serviceWorker.register('../sw.js?v=2', {
scope: '/a/',
})
})
Expand Down

0 comments on commit d98c8fb

Please sign in to comment.