mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-07-15 11:22:23 +08:00
first commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
name: pr-tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- "opened"
|
||||
- "reopened"
|
||||
- "synchronize"
|
||||
paths:
|
||||
- "src/**"
|
||||
- "build.mjs"
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
- run: npm ci
|
||||
- run: npm run lint
|
||||
- run: npm run build
|
||||
@@ -0,0 +1,61 @@
|
||||
name: pre-release
|
||||
on:
|
||||
workflow_dispatch:
|
||||
# push:
|
||||
# branches:
|
||||
# - main
|
||||
# paths:
|
||||
# - "src/**"
|
||||
# - "!src/**/*.json"
|
||||
# - "build.mjs"
|
||||
# tags-ignore:
|
||||
# - "v*"
|
||||
|
||||
jobs:
|
||||
build_and_release:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
|
||||
- uses: josStorer/get-current-time@v2
|
||||
id: current-time
|
||||
with:
|
||||
format: YYYY_MMDD_HHmm
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Chromium_Build_${{ steps.current-time.outputs.formattedTime }}
|
||||
path: build/chromium/*
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Firefox_Build_${{ steps.current-time.outputs.formattedTime }}
|
||||
path: build/firefox/*
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Chromium_Build_WithoutKatex_${{ steps.current-time.outputs.formattedTime }}
|
||||
path: build/chromium-without-katex/*
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Firefox_Build_WithoutKatex_${{ steps.current-time.outputs.formattedTime }}
|
||||
path: build/firefox-without-katex/*
|
||||
|
||||
- uses: marvinpinto/action-automatic-releases@v1.2.1
|
||||
with:
|
||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
automatic_release_tag: "latest"
|
||||
prerelease: true
|
||||
title: "Development Build"
|
||||
files: |
|
||||
build/chromium.zip
|
||||
build/firefox.zip
|
||||
build/chromium-without-katex.zip
|
||||
build/firefox-without-katex.zip
|
||||
@@ -0,0 +1,187 @@
|
||||
import { JSDOM } from 'jsdom'
|
||||
import fetch, { Headers } from 'node-fetch'
|
||||
|
||||
const config = {
|
||||
google: {
|
||||
inputQuery: ["input[name='q']"],
|
||||
sidebarContainerQuery: ['#rhs'],
|
||||
appendContainerQuery: ['#rcnt'],
|
||||
resultsContainerQuery: ['#rso'],
|
||||
},
|
||||
bing: {
|
||||
inputQuery: ["[name='q']"],
|
||||
sidebarContainerQuery: ['#b_context'],
|
||||
appendContainerQuery: [],
|
||||
resultsContainerQuery: ['#b_results'],
|
||||
},
|
||||
yahoo: {
|
||||
inputQuery: ["input[name='p']"],
|
||||
sidebarContainerQuery: ['#right', '.Contents__inner.Contents__inner--sub'],
|
||||
appendContainerQuery: ['#cols', '#contents__wrap'],
|
||||
resultsContainerQuery: [
|
||||
'#main-algo',
|
||||
'.searchCenterMiddle',
|
||||
'.Contents__inner.Contents__inner--main',
|
||||
'#contents',
|
||||
],
|
||||
},
|
||||
duckduckgo: {
|
||||
inputQuery: ["input[name='q']"],
|
||||
sidebarContainerQuery: ['.results--sidebar.js-results-sidebar'],
|
||||
appendContainerQuery: ['#links_wrapper'],
|
||||
resultsContainerQuery: ['.results'],
|
||||
},
|
||||
startpage: {
|
||||
inputQuery: ["input[name='query']"],
|
||||
sidebarContainerQuery: ['.layout-web__sidebar.layout-web__sidebar--web'],
|
||||
appendContainerQuery: ['.layout-web__body.layout-web__body--desktop'],
|
||||
resultsContainerQuery: ['.mainline-results'],
|
||||
},
|
||||
baidu: {
|
||||
inputQuery: ["input[id='kw']"],
|
||||
sidebarContainerQuery: ['#content_right'],
|
||||
appendContainerQuery: ['#container'],
|
||||
resultsContainerQuery: ['#content_left', '#results'],
|
||||
},
|
||||
kagi: {
|
||||
inputQuery: ["input[name='q']"],
|
||||
sidebarContainerQuery: ['.right-content-box._0_right_sidebar'],
|
||||
appendContainerQuery: ['#_0_app_content'],
|
||||
resultsContainerQuery: ['#main', '#app'],
|
||||
},
|
||||
yandex: {
|
||||
inputQuery: ["input[name='text']"],
|
||||
sidebarContainerQuery: ['#search-result-aside'],
|
||||
appendContainerQuery: [],
|
||||
resultsContainerQuery: ['#search-result'],
|
||||
},
|
||||
naver: {
|
||||
inputQuery: ["input[name='query']"],
|
||||
sidebarContainerQuery: ['#sub_pack'],
|
||||
appendContainerQuery: ['#content'],
|
||||
resultsContainerQuery: ['#main_pack', '#ct'],
|
||||
},
|
||||
brave: {
|
||||
inputQuery: ["input[name='q']"],
|
||||
sidebarContainerQuery: ['#side-right'],
|
||||
appendContainerQuery: [],
|
||||
resultsContainerQuery: ['#results'],
|
||||
},
|
||||
searx: {
|
||||
inputQuery: ["input[name='q']"],
|
||||
sidebarContainerQuery: ['#sidebar_results', '#sidebar'],
|
||||
appendContainerQuery: [],
|
||||
resultsContainerQuery: ['#urls', '#main_results', '#results'],
|
||||
},
|
||||
ecosia: {
|
||||
inputQuery: ["input[name='q']"],
|
||||
sidebarContainerQuery: ['.sidebar.web__sidebar'],
|
||||
appendContainerQuery: ['#main'],
|
||||
resultsContainerQuery: ['.mainline'],
|
||||
},
|
||||
neeva: {
|
||||
inputQuery: ["input[name='q']"],
|
||||
sidebarContainerQuery: ['.result-group-layout__stickyContainer-iDIO8'],
|
||||
appendContainerQuery: ['.search-index__searchHeaderContainer-2JD6q'],
|
||||
resultsContainerQuery: ['.result-group-layout__component-1jzTe', '#search'],
|
||||
},
|
||||
}
|
||||
|
||||
const urls = {
|
||||
google: ['https://www.google.com/search?q=hello'],
|
||||
bing: ['https://www.bing.com/search?q=hello', 'https://cn.bing.com/search?q=hello'],
|
||||
yahoo: ['https://search.yahoo.com/search?p=hello', 'https://search.yahoo.co.jp/search?p=hello'],
|
||||
duckduckgo: ['https://duckduckgo.com/s?q=hello'],
|
||||
startpage: [], // need redirect and post https://www.startpage.com/do/search?query=hello
|
||||
baidu: ['https://www.baidu.com/s?wd=hello'],
|
||||
kagi: [], // need login https://kagi.com/search?q=hello
|
||||
yandex: [], // need cookie https://yandex.com/search/?text=hello
|
||||
naver: ['https://search.naver.com/search.naver?query=hello'],
|
||||
brave: ['https://search.brave.com/search?q=hello'],
|
||||
searx: ['https://searx.tiekoetter.com/search?q=hello'],
|
||||
ecosia: [], // unknown verify method https://www.ecosia.org/search?q=hello
|
||||
neeva: [], // unknown verify method(FetchError: maximum redirect reached) https://neeva.com/search?q=hello
|
||||
}
|
||||
|
||||
const commonHeaders = {
|
||||
Accept:
|
||||
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
|
||||
Connection: 'keep-alive',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7', // for baidu
|
||||
}
|
||||
|
||||
const desktopHeaders = new Headers({
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/108.0.1462.76',
|
||||
...commonHeaders,
|
||||
})
|
||||
|
||||
const mobileHeaders = {
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Mobile Safari/537.36 Edg/108.0.1462.76',
|
||||
...commonHeaders,
|
||||
}
|
||||
|
||||
const desktopQueryNames = [
|
||||
'inputQuery',
|
||||
'sidebarContainerQuery',
|
||||
'appendContainerQuery',
|
||||
'resultsContainerQuery',
|
||||
]
|
||||
|
||||
const mobileQueryNames = ['inputQuery', 'resultsContainerQuery']
|
||||
|
||||
let errors = ''
|
||||
|
||||
async function verify(errorTag, urls, headers, queryNames) {
|
||||
await Promise.all(
|
||||
Object.entries(urls).map(([siteName, urlArray]) =>
|
||||
Promise.all(
|
||||
urlArray.map((url) =>
|
||||
fetch(url, {
|
||||
method: 'GET',
|
||||
headers: headers,
|
||||
})
|
||||
.then((response) => response.text())
|
||||
.then((text) => {
|
||||
const dom = new JSDOM(text)
|
||||
for (const queryName of queryNames) {
|
||||
const queryArray = config[siteName][queryName]
|
||||
if (queryArray.length === 0) continue
|
||||
|
||||
let foundQuery
|
||||
for (const query of queryArray) {
|
||||
const element = dom.window.document.querySelector(query)
|
||||
if (element) {
|
||||
foundQuery = query
|
||||
break
|
||||
}
|
||||
}
|
||||
if (foundQuery) {
|
||||
console.log(`${siteName} ${url} ${queryName}: ${foundQuery} passed`)
|
||||
} else {
|
||||
const error = `${siteName} ${url} ${queryName} failed`
|
||||
errors += errorTag + error + '\n'
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
errors += errorTag + error + '\n'
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
async function main() {
|
||||
console.log('Verify desktop search engine configs:')
|
||||
await verify('desktop: ', urls, desktopHeaders, desktopQueryNames)
|
||||
console.log('\nVerify mobile search engine configs:')
|
||||
await verify('mobile: ', urls, mobileHeaders, mobileQueryNames)
|
||||
|
||||
if (errors.length > 0) throw new Error('\n' + errors)
|
||||
else console.log('\nAll passed')
|
||||
}
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,59 @@
|
||||
name: tagged-release
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
build_and_release:
|
||||
runs-on: macos-12
|
||||
|
||||
steps:
|
||||
- run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: main
|
||||
|
||||
- name: Update manifest.json version
|
||||
uses: jossef/action-set-json-field@v2.1
|
||||
with:
|
||||
file: src/manifest.json
|
||||
field: version
|
||||
value: ${{ env.VERSION }}
|
||||
|
||||
- name: Update manifest.v2.json version
|
||||
uses: jossef/action-set-json-field@v2.1
|
||||
with:
|
||||
file: src/manifest.v2.json
|
||||
field: version
|
||||
value: ${{ env.VERSION }}
|
||||
|
||||
- name: Push files
|
||||
run: |
|
||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git commit -am "release v${{ env.VERSION }}"
|
||||
git push
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
|
||||
- uses: maxim-lobanov/setup-xcode@v1
|
||||
with:
|
||||
xcode-version: 14.2
|
||||
- run: sed -i '' "s/0.0.0/${{ env.VERSION }}/g" safari/project.patch
|
||||
- run: npm run build:safari
|
||||
|
||||
- uses: marvinpinto/action-automatic-releases@v1.2.1
|
||||
with:
|
||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
prerelease: false
|
||||
files: |
|
||||
build/chromium.zip
|
||||
build/firefox.zip
|
||||
build/safari.dmg
|
||||
build/chromium-without-katex.zip
|
||||
build/firefox-without-katex.zip
|
||||
@@ -0,0 +1,17 @@
|
||||
name: verify-configs
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "0 6 * * *"
|
||||
|
||||
jobs:
|
||||
verify_configs:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
- run: npm ci
|
||||
- run: npm run verify
|
||||
Reference in New Issue
Block a user