This commit is contained in:
许彦峰
2019-03-15 10:08:39 +08:00
commit e7adf25ccf
75 changed files with 25883 additions and 0 deletions

View File

@@ -0,0 +1 @@
console.log('background !')

View File

@@ -0,0 +1 @@
console.log('content-script!')

View File

@@ -0,0 +1,5 @@
var content = chrome.extension.getURL('js/content.js')
var script = document.createElement('script')
script.setAttribute('type', 'text/javascript')
script.setAttribute('src', content)
document.body.appendChild(script)

View File

@@ -0,0 +1,3 @@
chrome.devtools.panels.create('panel', 'img/logo.png', 'pages/panel.html', function (panel) {
console.log('hello from callback')
})

View File

@@ -0,0 +1,8 @@
import Vue from 'vue'
import root from './root.vue'
Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
el: '#root',
render: h => h(root)
})

View File

@@ -0,0 +1,18 @@
<template lang="pug">
div devtools
</template>
<script>
export default {
data: () => ({
}),
computed: { },
created () { },
mounted () { },
methods: { }
}
</script>
<style lang="scss">
div {
color: blue
}
</style>

View File

@@ -0,0 +1,22 @@
export default {
get (key) {
try {
return JSON.parse(localStorage.getItem(key))
} catch (e) {}
},
set (key, val) {
try {
localStorage.setItem(key, JSON.stringify(val))
} catch (e) {}
},
remove (key) {
try {
localStorage.removeItem(key)
} catch (e) {}
},
clear () {
try {
localStorage.clear()
} catch (e) {}
}
}

41
template/src/manifest.js Normal file
View File

@@ -0,0 +1,41 @@
module.exports = {
name: 'Vue Extension',
version: '1.0.0',
description: 'Vue.js Chrome Extension Template (wcer)',
author: 'yura',
manifest_version: 2,
icons: { '16': 'icons/16.png', '128': 'icons/128.png' },
permissions: [
'<all_urls>',
'*://*/*',
'activeTab',
'tabs',
'cookies',
'background',
'contextMenus',
'unlimitedStorage',
'storage',
'notifications',
'identity',
'identity.email'
],
browser_action: {
default_title: 'title',
default_popup: 'pages/popup.html'
},
background: {
persistent: false,
page: 'pages/background.html'
},
devtools_page: 'pages/devtools.html',
options_page: 'pages/options.html',
content_scripts: [{
js: [ 'js/inject.js' ],
run_at: 'document_end',
matches: ['<all_urls>'],
all_frames: true
}],
content_security_policy: "script-src 'self' 'unsafe-eval'; object-src 'self'",
web_accessible_resources: [ 'panel.html', 'js/content.js' ]
}

View File

@@ -0,0 +1,8 @@
import Vue from 'vue'
import root from './root.vue'
Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
el: '#root',
render: h => h(root)
})

View File

@@ -0,0 +1,18 @@
<template lang="pug">
div options
</template>
<script>
export default {
data: () => ({
}),
computed: { },
created () { },
mounted () { },
methods: { }
}
</script>
<style>
div {
color: blue
}
</style>

View File

@@ -0,0 +1,12 @@
import Vue from 'vue'
import root from './root.vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.config.productionTip = false
Vue.use(ElementUI)
/* eslint-disable no-new */
new Vue({
el: '#root',
render: h => h(root)
})

View File

@@ -0,0 +1,23 @@
<template lang="pug">
div
el-button(type="primary" @click="tab") New tab
</template>
<script>
export default {
data: () => ({
}),
computed: { },
created () { },
mounted () { },
methods: {
tab () {
chrome.tabs.create({ url: 'pages/app.html' })
}
}
}
</script>
<style lang="scss">
div {
color: blue
}
</style>

View File

@@ -0,0 +1,8 @@
import Vue from 'vue'
import root from './root.vue'
Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
el: '#root',
render: h => h(root)
})

18
template/src/tab/root.vue Normal file
View File

@@ -0,0 +1,18 @@
<template lang="pug">
div tab
</template>
<script>
export default {
data: () => ({
}),
computed: { },
created () { },
mounted () { },
methods: { }
}
</script>
<style lang="scss">
div {
color: blue
}
</style>