Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
va3y committed May 11, 2021
1 parent 135881a commit 5ff6cf7
Show file tree
Hide file tree
Showing 37 changed files with 1,003 additions and 226 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = {
root: true,
env: {
node: true
node: true,
webextensions: true
},
extends: [
'plugin:vue/essential',
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ pnpm-debug.log*
*.njsproj
*.sln
*.sw?

# Vue Browser Extension Output
*.pem
*.pub
*.zip
/artifacts
16 changes: 15 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
[
'@vue/cli-plugin-babel/preset',
{
modules: false
}
]
],
plugins: [
[
'component',
{
libraryName: 'element-ui',
styleLibraryName: 'theme-chalk'
}
]
]
}
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"serve": "vue-cli-service build --mode development --watch",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.5",
"element-ui": "^2.15.1",
"vue": "^2.6.11",
"vue-router": "^3.2.0",
"vuex": "^3.4.0"
Expand All @@ -21,14 +22,17 @@
"@vue/cli-service": "~4.5.0",
"@vue/eslint-config-standard": "^5.1.2",
"babel-eslint": "^10.1.0",
"babel-plugin-component": "^1.1.1",
"eslint": "^6.7.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^6.2.2",
"sass": "^1.26.5",
"sass-loader": "^8.0.2",
"node-sass": "^6.0.0",
"sass": "^1.32.12",
"sass-loader": "^10",
"vue-cli-plugin-browser-extension": "~0.25.2",
"vue-template-compiler": "^2.6.11"
}
}
6 changes: 6 additions & 0 deletions public/_locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extName": {
"message": "release-watcher",
"description": ""
}
}
12 changes: 12 additions & 0 deletions public/browser-extension.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<div id="app"></div>
</body>
</html>
Binary file added public/icons/128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/38.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/stopWatch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/watch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 0 additions & 32 deletions src/App.vue

This file was deleted.

7 changes: 7 additions & 0 deletions src/background/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
browser.runtime.onMessage.addListener(function (request, sender, sendResponse) {
console.log('Hello from the background')

// browser.tabs.executeScript({
// file: 'js/content-script.js'
// })
})
60 changes: 0 additions & 60 deletions src/components/HelloWorld.vue

This file was deleted.

25 changes: 25 additions & 0 deletions src/components/WatchItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<template>
<div>
<el-input :value="value" @input="$emit('input', $event)" size="mini">
<template #prepend> https://api.github.com/repos/ </template>
</el-input>
</div>
</template>

<script>
export default {
props: {
value: {
default: () => {
return {
settings: {
on: true
},
url: ''
}
},
required: true
}
}
}
</script>
26 changes: 26 additions & 0 deletions src/content-scripts/content-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const hTwoTags = document.getElementsByTagName('h2')

const releasesHeader = Array.from(hTwoTags).find(header => {
return (
header.firstElementChild?.baseURI + '/releases' ===
header.firstElementChild?.href
)
})

const imageUrl = chrome.runtime.getURL('images/watch.png')
const imageActiveUrl = chrome.runtime.getURL('images/stopWatch.png')

const watchImage = document.createElement('img')

let watchState = false
watchImage.src = imageUrl
watchImage.style.marginRight = '5px'

watchImage.addEventListener('click', (e) => {
watchState = !watchState
watchState
? (watchImage.src = imageUrl)
: (watchImage.src = imageActiveUrl)
})

releasesHeader.insertBefore(watchImage, releasesHeader.childNodes[0])
12 changes: 0 additions & 12 deletions src/main.js

This file was deleted.

32 changes: 32 additions & 0 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"manifest_version": 2,
"name": "__MSG_extName__",
"homepage_url": "http://localhost:8080/",
"description": "A Vue Browser Extension",
"default_locale": "en",
"permissions": ["activeTab", "<all_urls>", "*://*/*"],
"icons": {
"16": "icons/16.png",
"48": "icons/48.png",
"128": "icons/128.png"
},
"background": {
"scripts": ["js/background.js"],
"persistent": false
},
"browser_action": {
"default_popup": "popup.html",
"default_title": "__MSG_extName__",
"default_icon": {
"19": "icons/19.png",
"38": "icons/38.png"
}
},
"content_scripts": [
{
"matches": ["https://*.github.com/*"],
"js": ["js/content-script.js"]
}
],
"web_accessible_resources": ["images/watch.png", "images/stopWatch.png"]
}
14 changes: 14 additions & 0 deletions src/popup/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
<router-view />
</template>

<script>
export default { name: 'App' }
</script>

<style>
html {
width: 400px;
height: 400px;
}
</style>
3 changes: 3 additions & 0 deletions src/popup/layouts/Default.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<div><router-view /></div>
</template>
18 changes: 18 additions & 0 deletions src/popup/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Vue from 'vue'
import App from './App.vue'
import store from '@/store'
import router from './router'
import { Button, Input } from 'element-ui'

console.log(router)

Vue.use(Button)
Vue.use(Input)

/* eslint-disable no-new */
new Vue({
el: '#app',
render: h => h(App),
store,
router
})
13 changes: 13 additions & 0 deletions src/popup/router/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'

console.log(routes)

Vue.use(VueRouter)

const router = new VueRouter({
routes
})

export default router
27 changes: 27 additions & 0 deletions src/popup/router/routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Default from '@/popup/layouts/Default.vue'
import HomeView from '../views/HomeView.vue'

const routes = [
{
path: '/',
component: Default,
name: 'Default',
children: [
{
path: '',
name: 'Home',
component: HomeView
},
{
path: '/settings',
name: 'Settings',
component: () =>
import(
/* webpackChunkName: "SettingsView" */ '../views/SettingsView.vue'
)
}
]
}
]

export default routes
Loading

0 comments on commit 5ff6cf7

Please sign in to comment.