@@ -20,7 +20,7 @@ import { ProviderError, TranslateError } from "@/errors";
2020import { getUUID } from "@/utils/secure" ;
2121
2222export default class BingTranslateProvider extends BaseProvider {
23- apiUrlPlaceholder = "https://www.bing.com/ " ;
23+ apiUrlPlaceholder = "https://www.bing.com" ;
2424 originPlaceholder = "https://www.bing.com" ;
2525 headers = {
2626 "Content-Type" : "application/x-www-form-urlencoded" ,
@@ -56,7 +56,7 @@ export default class BingTranslateProvider extends BaseProvider {
5656 method,
5757 headers : {
5858 ...this . headers ,
59- Referer : this . origin ,
59+ Referer : ` ${ this . origin } /translator` ,
6060 Origin : this . origin ,
6161 ...headers ,
6262 } ,
@@ -183,22 +183,27 @@ export default class BingTranslateProvider extends BaseProvider {
183183 }
184184
185185 const { token, ig, creationTimestamp } = await this . getSession ( ) ;
186- const translatorID = tone === "Standard" ? 5026 : 5023 ;
186+ const isStandardTone = tone === "Standard" ;
187+ const translatorID = isStandardTone ? 5026 : 5023 ;
187188 const params = this . getParams ( {
188189 isVertical : "1" ,
189190 IG : ig ,
190191 IID : `translator.${ translatorID } ` ,
191192 } ) ;
192193
193- const body = new URLSearchParams ( [
194+ const bodyData : [ string , string ] [ ] = [
194195 [ "fromLang" , fromLang ] ,
195196 [ "to" , toLang ] ,
196197 [ "tryFetchingGenderDebiasedTranslations" , "true" ] ,
197198 [ "token" , token ] ,
198199 [ "key" , String ( creationTimestamp ) ] ,
199- [ "tone" , tone ] ,
200200 [ "text" , text ] ,
201- ] ) . toString ( ) ;
201+ ] ;
202+ if ( ! isStandardTone ) {
203+ bodyData . push ( [ "tone" , tone ] ) ;
204+ }
205+
206+ const body = new URLSearchParams ( bodyData ) . toString ( ) ;
202207 const res = await this . request < TranslateSuccessResponse > (
203208 `/ttranslatev3?${ params } ` ,
204209 body ,
0 commit comments