Dep Update

This commit is contained in:
Daniel Triendl 2024-10-14 10:59:19 +02:00
parent d107b1a49f
commit 1cbde09ac6
10 changed files with 2393 additions and 3018 deletions

View File

@ -15,8 +15,6 @@ const webpackConfig = {
}, },
externals: { externals: {
jquery: '$', jquery: '$',
axios: 'axios',
'axios-userscript-adapter': 'axiosGmxhrAdapter'
}, },
module: { module: {
rules: [ rules: [

5311
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -24,33 +24,32 @@
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
"axios": "^1.4.0", "chrono-node": "^2.7.7",
"axios-userscript-adapter": "^0.2.0-alpha.2", "@trim21/gm-fetch": "^0.1.15"
"chrono-node": "^2.6.3"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.22.5", "@types/greasemonkey": "^4.0.7",
"@babel/preset-env": "^7.22.5", "@babel/core": "^7.25.8",
"@typescript-eslint/eslint-plugin": "^5.60.1", "@babel/preset-env": "^7.25.8",
"@typescript-eslint/parser": "^5.60.1", "@typescript-eslint/eslint-plugin": "^8.8.1",
"babel-loader": "^9.1.2", "@typescript-eslint/parser": "^8.8.1",
"babel-loader": "^9.2.1",
"browserslist": "^4.21.9", "browserslist": "^4.21.9",
"css-loader": "^6.8.1", "css-loader": "^7.1.2",
"eslint": "^8.43.0", "eslint": "^9.12.0",
"eslint-config-standard": "^17.1.0", "eslint-plugin-import": "^2.31.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-node": "11.1.0", "eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "^6.1.1", "eslint-plugin-promise": "^7.1.0S",
"less": "4.1.3", "less": "4.2.0",
"less-loader": "^11.1.3", "less-loader": "^12.2.0",
"style-loader": "^3.3.3", "style-loader": "^4.0.0",
"ts-loader": "^9.4.3", "ts-loader": "^9.5.1",
"typescript": "^5.1.3", "typescript": "^5.6.3",
"userscript-metadata-webpack-plugin": "^0.4.0", "userscript-metadata-webpack-plugin": "^0.4.0",
"webpack": "^5.88.0", "webpack": "^5.95.0",
"webpack-bundle-analyzer": "^4.9.0", "webpack-bundle-analyzer": "^4.10.2",
"webpack-cli": "^5.1.4", "webpack-cli": "^5.1.4",
"webpack-livereload-plugin": "3.0.2", "webpack-livereload-plugin": "3.0.2",
"webpack-merge": "^5.9.0" "webpack-merge": "^6.0.1"
} }
} }

View File

@ -1,6 +1,7 @@
import * as chrono from 'chrono-node' import * as chrono from 'chrono-node'
import { TapiContact } from './tapi-contact' import { TapiContact } from './tapi-contact'
import { axios, extractNumber } from './utils' import { extractNumber } from './utils'
import GM_fetch from '@trim21/gm-fetch'
export class CallHistory { export class CallHistory {
private callerIds: { [number: string]: TapiContact } = {} private callerIds: { [number: string]: TapiContact } = {}
@ -85,10 +86,10 @@ export class CallHistory {
if (this.callerIds[number] !== undefined) { if (this.callerIds[number] !== undefined) {
this.updateCallHistoryEntry(element, this.callerIds[number]) this.updateCallHistoryEntry(element, this.callerIds[number])
} else { } else {
var response = await axios.get<TapiContact>('http://cpatapi.cpsrvweb2016.cp-austria.at/callerid/' + encodeURIComponent(number)) var response = await GM_fetch('http://cpatapi.cpsrvweb2016.cp-austria.at/callerid/' + encodeURIComponent(number))
var callerId: TapiContact = { tD_NAME: '' } var callerId: TapiContact = { tD_NAME: '' }
if (response.status === 200) { if (response.status === 200) {
callerId = response.data callerId = await response.json() as TapiContact
} }
console.log('TAPI call histroy callerid response', number, response, callerId) console.log('TAPI call histroy callerid response', number, response, callerId)
this.callerIds[number] = callerId this.callerIds[number] = callerId

View File

@ -1,5 +1,6 @@
import GM_fetch from '@trim21/gm-fetch'
import { TapiContact } from './tapi-contact' import { TapiContact } from './tapi-contact'
import { axios, extractNumber } from './utils' import { extractNumber } from './utils'
export class CallNotification { export class CallNotification {
public async showCallNotification (element: HTMLElement) { public async showCallNotification (element: HTMLElement) {
@ -13,19 +14,19 @@ export class CallNotification {
} }
console.log('TAPI searching callerid for', number) console.log('TAPI searching callerid for', number)
var response = await axios.get<TapiContact>('http://cpatapi.cpsrvweb2016.cp-austria.at/callerid/' + encodeURIComponent(number)) var response = await GM_fetch('http://cpatapi.cpsrvweb2016.cp-austria.at/callerid/' + encodeURIComponent(number))
console.log('TAPI callerid response', response) console.log('TAPI callerid response', response)
var notification = { var notification = {
text: number text: number
} }
if (response.status === 200) { if (response.status === 200) {
var callerId = response.data var callerId = await response.json() as TapiContact
if (callerId) { if (callerId) {
notification.text = callerId.tD_NAME + '\r\n' + number + ' (' + callerId.tD_MEDIUM + ')' notification.text = callerId.tD_NAME + '\r\n' + number + ' (' + callerId.tD_MEDIUM + ')'
} }
} }
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
GM.notification(notification) GM.notification(notification.text, 'TAPI Anruf')
} }
} }

3
src/decs.d.ts vendored
View File

@ -1,3 +0,0 @@
declare module 'axios-userscript-adapter'
declare const GM: any

View File

@ -1,7 +1,8 @@
import './search.css' import './search.css'
import { TapiContact } from './tapi-contact' import { TapiContact } from './tapi-contact'
import { debounce } from './debounce' import { debounce } from './debounce'
import { axios, fireChangeEvents } from './utils' import { fireChangeEvents } from './utils'
import GM_fetch from '@trim21/gm-fetch'
export class Search { export class Search {
private currentSearchText = '' private currentSearchText = ''
@ -102,9 +103,9 @@ export class Search {
return return
} }
console.log('Searching TAPI') console.log('Searching TAPI')
var response = await axios.get<TapiContact[]>('http://cpatapi.cpsrvweb2016.cp-austria.at/search?query=' + encodeURIComponent(searchText)) var response = await GM_fetch('http://cpatapi.cpsrvweb2016.cp-austria.at/search?query=' + encodeURIComponent(searchText))
console.log('TAPI Search response', response) console.log('TAPI Search response', response)
var contacts = response.data var contacts = await response.json() as TapiContact[]
console.log('TAPI Contacts', contacts) console.log('TAPI Contacts', contacts)
this.removeSearchResults() this.removeSearchResults()
this.currentSearchText = searchText this.currentSearchText = searchText

View File

@ -1,6 +1,6 @@
import './status.css'; import './status.css';
import { axios } from './utils';
import { ZcStatus } from './zc-status'; import { ZcStatus } from './zc-status';
import GM_fetch from "@trim21/gm-fetch";
declare function waitForKeyElements(selectorOrFunction: any, callback: any, waitOnce: boolean): any; declare function waitForKeyElements(selectorOrFunction: any, callback: any, waitOnce: boolean): any;
@ -26,10 +26,9 @@ export class Status {
private async checkStatus() { private async checkStatus() {
if (this._enabled) { if (this._enabled) {
try { try {
var response = await axios.get<ZcStatus>('http://cpatapi.cpsrvweb2016.cp-austria.at/availability/' + encodeURIComponent(this._user)); var response = await GM_fetch('http://cpatapi.cpsrvweb2016.cp-austria.at/availability/' + encodeURIComponent(this._user));
if (response.status == 200) { if (response.status == 200) {
var status = response.data; var status = await response.json() as ZcStatus;
if (this._currentStatus !== status.loggedIn) { if (this._currentStatus !== status.loggedIn) {
this._currentStatus = status.loggedIn; this._currentStatus = status.loggedIn;
console.log('New status, loggedIn', this._currentStatus); console.log('New status, loggedIn', this._currentStatus);

View File

@ -1,23 +1,3 @@
/**
* @typedef {Object} AxiosResponse
* @property {Object} data
* @property {Object} headers
* @property {Object} config
* @property {Object} request
* @property {number} code
* @property {string} statusText
*/
/**
* @typedef {Object} AxiosError
* @property {AxiosResponse} response
*/
import axios from 'axios'
import adapter from 'axios-userscript-adapter'
axios.defaults.adapter = adapter
export { axios }
export function extractNumber (s: string) { export function extractNumber (s: string) {
var match = /(\+?[0-9]{4,})/.exec(s) var match = /(\+?[0-9]{4,})/.exec(s)
if (!match) { if (!match) {

View File

@ -2,8 +2,8 @@
"compilerOptions": { "compilerOptions": {
"outDir": "./dist/", "outDir": "./dist/",
"noImplicitAny": true, "noImplicitAny": true,
"module": "es6", "module": "ESNext",
"target": "es6", "target": "ES2022",
"allowJs": true, "allowJs": true,
"moduleResolution": "node" "moduleResolution": "node"
} }