suhaotian / ucrx

unzip .crx from terminal...

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bing t

suhaotian opened this issue · comments

commented
const fetch = require('fetch-cookie')(require('node-fetch'))

let cacheFetch = null
function bing(text, from, to) {
  const url = `https://www.bing.com/translator/api/Translate/TranslateArray?from=${from}&to=${to}`
  cacheFetch = cacheFetch ? cacheFetch : fetch('https://www.bing.com/Translator', {credentials: 'include',})
  return cacheFetch.then(() => {
    return fetch(url, {
      method: 'POST', 
      credentials: 'include',
      body: JSON.stringify([{id:'', text: text}]),
      headers: {
        'X-Requested-With': 'XMLHttpRequest',
        'Content-Type': 'application/json; charset=UTF-8',
      }
    }).then(res => res.json())
  })
}


module.exports = bing