iphone-xudale 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. package/.eslintrc.json +3 -0
  2. package/app/(pages)/options/page.tsx +720 -0
  3. package/app/(pages)/popup/page.tsx +166 -0
  4. package/app/(pages)/tips/page.tsx +40 -0
  5. package/app/components/DropListBox.tsx +157 -0
  6. package/app/components/SVGPlay.tsx +14 -0
  7. package/app/favicon.ico +0 -0
  8. package/app/globals.css +27 -0
  9. package/app/layout.tsx +15 -0
  10. package/app/page.tsx +3 -0
  11. package/app/scripts/content/checkoutSteps.ts +341 -0
  12. package/app/scripts/content/doFroApplePages.ts +206 -0
  13. package/app/scripts/content/getPageInitInfo.ts +49 -0
  14. package/app/scripts/content/getStoreCanPickInfo.ts +251 -0
  15. package/app/scripts/content/goOrderSteps.ts +179 -0
  16. package/app/scripts/content/index.ts +56 -0
  17. package/app/scripts/content/playSystemNotifacation.ts +39 -0
  18. package/app/scripts/content/sendSelfNotificatioin.ts +27 -0
  19. package/app/scripts/inject/index.ts +18 -0
  20. package/app/shared/constants.ts +236 -0
  21. package/app/shared/interface.ts +25 -0
  22. package/app/shared/location/city.json +1774 -0
  23. package/app/shared/location/county.json +17115 -0
  24. package/app/shared/location/province.json +94 -0
  25. package/app/shared/util.ts +93 -0
  26. package/buildAfter.js +86 -0
  27. package/bunBuild.ts +54 -0
  28. package/extension/content-script.js +7 -0
  29. package/extension/favicon.ico +0 -0
  30. package/extension/icons/icon128.png +0 -0
  31. package/extension/icons/icon16.png +0 -0
  32. package/extension/icons/icon19-disable.png +0 -0
  33. package/extension/icons/icon19.png +0 -0
  34. package/extension/icons/icon32.png +0 -0
  35. package/extension/icons/icon38.png +0 -0
  36. package/extension/icons/icon48.png +0 -0
  37. package/extension/inject-script.js +1 -0
  38. package/extension/manifest.json +38 -0
  39. package/extension/service-worker.js +62 -0
  40. package/extension.next.config.js +25 -0
  41. package/icon_generator.py +30 -0
  42. package/middleware.ts +21 -0
  43. package/next.config.js +15 -0
  44. package/package.json +67 -0
  45. package/postcss.config.js +6 -0
  46. package/public/assets/images/SCR-20230916-nbkz.png +0 -0
  47. package/public/assets/images/SCR-20230916-nbyv.png +0 -0
  48. package/public/assets/images/SCR-20230916-ncte.png +0 -0
  49. package/public/assets/images/SCR-20230916-ndgw.png +0 -0
  50. package/public/assets/images/SCR-20230916-ndks.png +0 -0
  51. package/public/assets/images/SCR-20230916-neaa.png +0 -0
  52. package/public/assets/images/SCR-20230916-neeq.jpeg +0 -0
  53. package/public/assets/images/SCR-20230916-nfkt.png +0 -0
  54. package/public/assets/images/SCR-20230919-ulfn.png +0 -0
  55. package/public/assets/images/SCR-20230919-ulzd.png +0 -0
  56. package/public/assets/images/SCR-20230919-uocr.png +0 -0
  57. package/public/icon_original.png +0 -0
  58. package/public/next.svg +1 -0
  59. package/public/vercel.svg +1 -0
  60. package/tailwind.config.ts +20 -0
  61. package/tsconfig.json +27 -0
  62. package/types/global.d.ts +19 -0
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1 @@
1
+ (function(c){var d=c.pushState;c.pushState=function(f,j,b){if(typeof c.onpushstate=="function")c.onpushstate({state:f});return b=b&&b.search(/^http/)>-1?b:"",window.postMessage({action:"doFroApplePages",url:b},"*"),d.apply(c,arguments)},console.log(c.pushState)})(history);
@@ -0,0 +1,38 @@
1
+ {
2
+ "manifest_version": 3,
3
+ "name": "iPhoneOrder.2023",
4
+ "description": "iPhoneOrder",
5
+ "version": "1.0",
6
+ "permissions": ["ttsEngine","tts", "activeTab", "scripting", "contextMenus", "tabs","storage"],
7
+ "host_permissions": [ "https://*.apple.com.cn/*"],
8
+ "icons": {
9
+ "16": "icons/icon16.png",
10
+ "48": "icons/icon48.png",
11
+ "128": "icons/icon128.png"
12
+ },
13
+ "content_security_policy": {
14
+ "extension_pages": "script-src 'self';"
15
+ },
16
+ "options_page": "dist/options.html",
17
+ "action": {
18
+ "default_title": "iPhoneOrder",
19
+ "default_popup": "dist/popup.html"
20
+ },
21
+ "background": {
22
+ "service_worker": "service-worker.js"
23
+ },
24
+ "web_accessible_resources": [
25
+ {
26
+ "resources": ["inject-script.js", "dist/tips.html", "icons/icon38.png"],
27
+ "matches": ["https://*.apple.com.cn/*"]
28
+ }
29
+ ],
30
+ "content_scripts": [
31
+ {
32
+ "js": ["content-script.js"],
33
+ "matches": [
34
+ "https://*.apple.com.cn/*"
35
+ ]
36
+ }
37
+ ]
38
+ }
@@ -0,0 +1,62 @@
1
+ const Match_URL = ['apple.com.cn']
2
+
3
+ const mainPage = './dist/main.html'
4
+ const optionsPage = './dist/options.html'
5
+
6
+ const defaultVoiceInfo = {
7
+ text: `抢到了`,
8
+ times: 1,
9
+ }
10
+
11
+ chrome.action.onClicked.addListener(async tab => {
12
+ console.log(`chrome action onClicked`)
13
+ if (!tab.url) return
14
+ const url = new URL(tab.url)
15
+ const tabId = tab.id
16
+ const isInMatchUrl = Match_URL.some(function (matchurl) {
17
+ return url.origin.includes(matchurl)
18
+ })
19
+
20
+ if (isInMatchUrl) {
21
+ // inject script in page first
22
+ chrome.scripting.executeScript(
23
+ {
24
+ target: { tabId },
25
+ world: 'MAIN',
26
+ files: ['./inject-script.js'],
27
+ },
28
+ () => {
29
+ const command = 'iphone_order'
30
+ // after inject function in page window, then call it in page window
31
+ chrome.scripting.executeScript({
32
+ target: { tabId },
33
+ world: 'MAIN',
34
+ args: [{ command, tabUrl: url.href }],
35
+ func: (...args) => {
36
+ // injectScript(...args)
37
+ },
38
+ })
39
+ }
40
+ )
41
+ }
42
+ })
43
+
44
+ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
45
+ const {
46
+ data, extensionId, voiceInfo
47
+ } = message || {}
48
+ const { text, times, lang, voiceName} = voiceInfo || {}
49
+ if((data == 'bellring') && extensionId && text && times){
50
+ let voiceOption = {}
51
+ if(lang && voiceName){
52
+ voiceOption = {
53
+ lang, voiceName
54
+ }
55
+ }
56
+ chrome.tts.speak(text, voiceOption);
57
+ // 播放N次
58
+ for(let s=1; s<times; s++){
59
+ chrome.tts.speak(text, voiceOption, {'enqueue': true})
60
+ }
61
+ }
62
+ });
@@ -0,0 +1,25 @@
1
+ /** @type {import('next').NextConfig} */
2
+ console.log(`BUILD_TYPE`, process.env.BUILD_TYPE)
3
+ const nextConfig = {
4
+ output: 'export',
5
+ // Optional: Add a trailing slash to all paths `/about` -> `/about/`
6
+ // trailingSlash: true,
7
+ // Optional: Change the output directory `out` -> `dist`
8
+ distDir: 'extension/dist',
9
+ cleanDistDir: true,
10
+ dir: "./app/main/",
11
+ // after build, we need to move inline script from main.html into a single js file,
12
+ // otherwise, chrome will not allow inline script to run
13
+ assetPrefix: ".",
14
+ productionBrowserSourceMaps: true,
15
+ reactStrictMode: true,
16
+ webpack: (config, options) => {
17
+ config.experiments = {
18
+ asyncWebAssembly: true,
19
+ layers: true,
20
+ }
21
+ return config
22
+ },
23
+ }
24
+
25
+ module.exports = nextConfig
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import sys
4
+ from PIL import Image
5
+ from PIL import ImageOps
6
+
7
+
8
+ def usage():
9
+ print('usage: ./icon_generator.py <src_image>')
10
+
11
+
12
+ def main(filename):
13
+ icon_sizes = (16, 19, 32, 38, 48, 128)
14
+ src_image = Image.open(filename, 'r')
15
+
16
+ for size in icon_sizes:
17
+ icon = src_image.resize((size, size), Image.LANCZOS)
18
+ icon.save('extension/icons/icon{size}.png'.format(size=size))
19
+ if size == 19:
20
+ grayscale_icon = ImageOps.grayscale(icon)
21
+ grayscale_icon.save('extension/icons/icon{size}-disable.png'.format(size=size))
22
+
23
+
24
+ if __name__ == '__main__':
25
+ if len(sys.argv) != 2:
26
+ usage()
27
+ sys.exit(1)
28
+
29
+ filename = sys.argv[1]
30
+ main(filename)
package/middleware.ts ADDED
@@ -0,0 +1,21 @@
1
+ import { NextRequest, NextResponse } from 'next/server'
2
+
3
+ // This function can be marked `async` if using `await` inside
4
+ export async function middleware(request: NextRequest) {
5
+ console.log(`this.is middleware`, request.body)
6
+
7
+ // 允许静态html跨域
8
+ if(request.method === 'OPTIONS'){
9
+ const response = new NextResponse;
10
+ console.log(`this.is middleware OPTIONS`, request.body)
11
+ response.headers.set("Access-Control-Allow-Origin", "*");
12
+ response.headers.set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE');
13
+ response.headers.set('Access-Control-Allow-Headers', 'Content-Type, Authorization');
14
+ return response;
15
+ }
16
+ }
17
+
18
+ // See "Matching Paths" below to learn more
19
+ export const config = {
20
+ matcher: '/api/:path*',
21
+ }
package/next.config.js ADDED
@@ -0,0 +1,15 @@
1
+ /** @type {import('next').NextConfig} */
2
+ const extensionNextConfig = require('./extension.next.config')
3
+
4
+ const nextConfig = process.env.BUILD_TYPE == `extension` ? extensionNextConfig : {
5
+ reactStrictMode: true,
6
+ webpack: (config, options) => {
7
+ config.experiments = {
8
+ asyncWebAssembly: true,
9
+ layers: true,
10
+ }
11
+ return config
12
+ },
13
+ }
14
+
15
+ module.exports = nextConfig
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "iphone-xudale",
3
+ "version": "0.2.9",
4
+ "private": false,
5
+ "scripts": {
6
+ "dev": "next dev",
7
+ "build": "next build",
8
+ "start": "next start",
9
+ "lint": "next lint",
10
+ "bunbuild": "bun ./bunBuild.ts",
11
+ "afterbuild": "node ./buildAfter.js",
12
+ "zip:extension": "cd ./extension && zip -r ../iPhoneOrder.zip . && cd ..",
13
+ "build:extension": "cross-env-shell BUILD_TYPE=extension bun run build:extension:after; bun run bunbuild; bun zip:extension",
14
+ "build:extension:after": "bun run build && bun run afterbuild",
15
+ "eslint": "eslint \"app/**/*.{js,jsx,ts,tsx}\" --ignore-pattern \"app/lib/\" --ignore-pattern \"app/shared/\"",
16
+ "check-types": "tsc --noemit",
17
+ "eslint:commit": "git diff --cached --name-only | grep -E 'app.*\\.[jt]sx?$' | xargs ./node_modules/.bin/eslint --quiet",
18
+ "eslint:quiet": "eslint \"app/**/*.{js,jsx,ts,tsx}\" --ignore-pattern \"app/lib/\" --ignore-pattern \"app/shared/\" --quiet",
19
+ "prettier:single": "prettier --single-quote --no-semi --trailing-comma es5 --print-width 120 --tab-width 4 --arrow-parens avoid --write",
20
+ "prettier": "prettier --single-quote --no-semi --trailing-comma es5 --print-width 120 --tab-width 4 --arrow-parens avoid --write \"app/**/*.{js,jsx,ts,tsx}\"",
21
+ "prettier:check": "npm run prettier -- --list-different",
22
+ "lint-staged": "lint-staged"
23
+ },
24
+ "pre-commit": "lint-staged",
25
+ "lint-staged": {
26
+ "app/**/*.{js,jsx,ts,tsx}": [
27
+ "npm run eslint:commit",
28
+ "prettier --single-quote --no-semi --trailing-comma es5 --print-width 120 --tab-width 4 --arrow-parens avoid --write \"!app/lib/**\"",
29
+ "git add"
30
+ ]
31
+ },
32
+ "dependencies": {
33
+ "@headlessui/react": "^1.7.17",
34
+ "@heroicons/react": "^2.0.18",
35
+ "@types/node": "20.6.0",
36
+ "@types/react": "18.2.21",
37
+ "@types/react-dom": "18.2.7",
38
+ "autoprefixer": "10.4.15",
39
+ "cheerio": "^1.0.0-rc.12",
40
+ "cross-fetch": "^4.0.0",
41
+ "eslint": "8.49.0",
42
+ "eslint-config-next": "13.4.19",
43
+ "lodash": "^4.17.21",
44
+ "next": "13.4.19",
45
+ "postcss": "8.4.29",
46
+ "react": "18.2.0",
47
+ "react-dom": "18.2.0",
48
+ "tailwindcss": "3.3.3",
49
+ "typescript": "5.2.2"
50
+ },
51
+ "devDependencies": {
52
+ "@babel/cli": "^7.22.15",
53
+ "@babel/core": "^7.22.17",
54
+ "@babel/preset-env": "^7.22.15",
55
+ "@babel/preset-typescript": "^7.22.15",
56
+ "@types/lodash": "^4.14.198",
57
+ "babel-plugin-transform-remove-console": "^6.9.4",
58
+ "cross-env": "^7.0.3",
59
+ "lint-staged": "^14.0.1",
60
+ "pre-commit": "^1.2.2",
61
+ "prettier": "^3.0.3"
62
+ },
63
+ "main": "buildAfter.js",
64
+ "author": "order",
65
+ "license": "ISC",
66
+ "description": ""
67
+ }
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ }
Binary file
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 283 64"><path fill="black" d="M141 16c-11 0-19 7-19 18s9 18 20 18c7 0 13-3 16-7l-7-5c-2 3-6 4-9 4-5 0-9-3-10-7h28v-3c0-11-8-18-19-18zm-9 15c1-4 4-7 9-7s8 3 9 7h-18zm117-15c-11 0-19 7-19 18s9 18 20 18c6 0 12-3 16-7l-8-5c-2 3-5 4-8 4-5 0-9-3-11-7h28l1-3c0-11-8-18-19-18zm-10 15c2-4 5-7 10-7s8 3 9 7h-19zm-39 3c0 6 4 10 10 10 4 0 7-2 9-5l8 5c-3 5-9 8-17 8-11 0-19-7-19-18s8-18 19-18c8 0 14 3 17 8l-8 5c-2-3-5-5-9-5-6 0-10 4-10 10zm83-29v46h-9V5h9zM37 0l37 64H0L37 0zm92 5-27 48L74 5h10l18 30 17-30h10zm59 12v10l-3-1c-6 0-10 4-10 10v15h-9V17h9v9c0-5 6-9 13-9z"/></svg>
@@ -0,0 +1,20 @@
1
+ import type { Config } from 'tailwindcss'
2
+
3
+ const config: Config = {
4
+ content: [
5
+ './pages/**/*.{js,ts,jsx,tsx,mdx}',
6
+ './components/**/*.{js,ts,jsx,tsx,mdx}',
7
+ './app/**/*.{js,ts,jsx,tsx,mdx}',
8
+ ],
9
+ theme: {
10
+ extend: {
11
+ backgroundImage: {
12
+ 'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
13
+ 'gradient-conic':
14
+ 'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
15
+ },
16
+ },
17
+ },
18
+ plugins: [],
19
+ }
20
+ export default config
package/tsconfig.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es5",
4
+ "lib": ["dom", "dom.iterable", "esnext"],
5
+ "allowJs": true,
6
+ "skipLibCheck": true,
7
+ "strict": true,
8
+ "noEmit": true,
9
+ "esModuleInterop": true,
10
+ "module": "esnext",
11
+ "moduleResolution": "bundler",
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "jsx": "preserve",
15
+ "incremental": true,
16
+ "plugins": [
17
+ {
18
+ "name": "next"
19
+ }
20
+ ],
21
+ "paths": {
22
+ "@/*": ["./*"]
23
+ }
24
+ },
25
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
26
+ "exclude": ["node_modules"]
27
+ }
@@ -0,0 +1,19 @@
1
+ interface History {
2
+ onpushstate: Function
3
+ }
4
+
5
+ interface HTMLInputElement {
6
+ _valueTracker: any
7
+ }
8
+
9
+ interface Event {
10
+ simulated?: boolean
11
+ }
12
+
13
+ interface Chrome {
14
+ [index: string]: any,
15
+ }
16
+
17
+ // 扩展全局对象类型定义
18
+ declare const chrome: Chrome;
19
+