版本迭代
This commit is contained in:
61
src/entry/background.js
Normal file
61
src/entry/background.js
Normal file
@@ -0,0 +1,61 @@
|
||||
|
||||
/**
|
||||
利用chrome的fetch来避免跨域
|
||||
**/
|
||||
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
||||
if (request.type == 'api') {
|
||||
new Promise((resolve, reject) => {
|
||||
let headers = {};
|
||||
|
||||
if (request.needMallId) {
|
||||
headers.Mallid = request.mallId;
|
||||
}
|
||||
headers['Content-Type'] = 'application/json';
|
||||
|
||||
headers.cookie = getCookie();
|
||||
|
||||
fetch(request.url, {
|
||||
'headers': headers,
|
||||
'method': 'POST',
|
||||
'referrerPolicy': 'no-referrer',
|
||||
'credentials': 'include',
|
||||
'body': JSON.stringify(request.data),
|
||||
'mode': 'cors'
|
||||
}).then((res) => {
|
||||
resolve(res.json());
|
||||
});
|
||||
}).then((res) => {
|
||||
sendResponse(res);
|
||||
});
|
||||
} else if (request.type == 'notify') {
|
||||
chrome.notifications.create(
|
||||
"" + Math.random(), {
|
||||
type: "basic",
|
||||
title: "TEMU助手",
|
||||
message: "您的商品【" + request.productName + "】成功加入发货台,请尽快处理",
|
||||
iconUrl: "./icons/48.png"
|
||||
}, null
|
||||
)
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
chrome.action.onClicked.addListener(function () {
|
||||
chrome.tabs.create({
|
||||
url: "./popup.html"
|
||||
}, function (tab) {
|
||||
console.log('tab is:' + tab);
|
||||
});
|
||||
});
|
||||
|
||||
function getCookie() {
|
||||
const url = new URL("https://kuajing.pinduoduo.com/");
|
||||
let cStr = '';
|
||||
chrome.cookies.getAll({domain: url.host}, (cookie) => {
|
||||
cookie.map((c) => {
|
||||
cStr += c.name + '=' + c.value + ';';
|
||||
});
|
||||
});
|
||||
return cStr;
|
||||
}
|
||||
1
src/entry/content.js
Normal file
1
src/entry/content.js
Normal file
@@ -0,0 +1 @@
|
||||
console.log('hello world content todo something~')
|
||||
27
src/entry/popup.js
Normal file
27
src/entry/popup.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import Vue from 'vue'
|
||||
import App from '../view/popup.vue'
|
||||
import store from '../store'
|
||||
import router from '../router'
|
||||
import ElementUI from 'element-ui'
|
||||
import '../assets/css/element-variables.scss'
|
||||
import instance from '../api'
|
||||
import utils from '../utils'
|
||||
import install from '../utils/install'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
Vue.use(ElementUI)
|
||||
Vue.config.productionTip = false
|
||||
|
||||
var relativeTime = require('dayjs/plugin/relativeTime')
|
||||
require('dayjs/locale/zh-cn')
|
||||
dayjs.extend(relativeTime)
|
||||
Vue.prototype.$dayjs = dayjs
|
||||
|
||||
Object.keys(utils).forEach(v => Vue.prototype[`$${v}`] = utils[v])
|
||||
Vue.prototype.$http = instance
|
||||
|
||||
new Vue({
|
||||
store,
|
||||
router,
|
||||
render: (h) => h(App)
|
||||
}).$mount('#app')
|
||||
Reference in New Issue
Block a user