Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fiahfy committed Oct 30, 2018
0 parents commit 96d95ce
Show file tree
Hide file tree
Showing 25 changed files with 6,077 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["@babel/env"],
"plugins": ["@babel/transform-runtime"]
}
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
14 changes: 14 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
root: true,
env: {
node: true
},
globals: {
chrome: true
},
extends: [
'eslint:recommended',
'plugin:prettier/recommended',
'plugin:vue/recommended'
]
}
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
node_modules

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# Chrome Extension
app
dist
!.gitkeep
5 changes: 5 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
semi: false,
singleQuote: true,
arrowParens: 'always'
}
24 changes: 24 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
os: osx
osx_image: xcode10
language: node_js
node_js: 10

cache:
yarn: true
directories:
- node_modules

script:
- yarn test
- yarn package

deploy:
provider: releases
api_key: $GH_TOKEN
file_glob: true
file: dist/*
skip_cleanup: true

branches:
only:
- master
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 fiahfy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# YouTube Live Chat Filter
[![Build Status](https://travis-ci.org/fiahfy/youtube-live-chat-filter.svg?branch=master)](https://travis-ci.org/fiahfy/youtube-live-chat-filter)

> Chrome Extension for filtering messages on YouTube Live Chat.

## Features
* Filter messages added NG list.


## Screenshot
![screenshot](./build/screenshots/screenshot.png?raw=true)


## Installation
1. Download `.zip` file from [releases page](https://github.com/fiahfy/youtube-live-chat-filter/releases).
2. Unzip this file.
3. Open URL `chrome://extensions/` by Google Chrome.
4. Enable developer mode.
5. Drag and drop `app` directory.


## Development
``` bash
# install dependencies
yarn

# watch files changed and reload extension
yarn dev
```
56 changes: 56 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "youtube-live-chat-filter",
"description": "Filter Messages on YouTube Live Chat",
"version": "0.0.1",
"author": {
"name": "fiahfy",
"email": "[email protected]",
"url": "http://fiahfy.blogspot.com/"
},
"dependencies": {
"vue": "^2.5.16",
"vuetify": "^1.0.17",
"vuex": "^3.0.1"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/register": "^7.0.0",
"@babel/runtime": "^7.0.0",
"babel-loader": "^8.0.2",
"copy-webpack-plugin": "^4.5.1",
"css-loader": "^1.0.0",
"eslint": "^5.6.0",
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-prettier": "^3.0.0",
"eslint-plugin-vue": "^5.0.0-beta.3",
"file-loader": "^2.0.0",
"html-webpack-plugin": "^3.2.0",
"prettier": "^1.14.3",
"vue-loader": "^15.0.5",
"vue-template-compiler": "^2.5.16",
"webpack": "^4.0.1",
"webpack-chrome-extension-reloader": "^0.8.3",
"webpack-cli": "^3.0.2"
},
"keywords": [
"chrome extension",
"vue",
"vuetify",
"webpack",
"youtube"
],
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/fiahfy/youtube-live-chat-filter"
},
"scripts": {
"build": "webpack",
"dev": "webpack -w --config webpack.config.dev.babel.js",
"lint": "eslint -f codeframe --ext .js --ignore-path .gitignore .",
"package": "NODE_ENV=production npm run build && mkdir -p dist && zip -r dist/youtube-live-chat-filter.zip app",
"test": "npm run lint"
}
}
Binary file added src/assets/icon-off48.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 src/assets/icon-on48.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 src/assets/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/assets/options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link href='https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons' rel="stylesheet">
</head>
<body>
<div id="app" />
</body>
</html>
69 changes: 69 additions & 0 deletions src/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { defaults } from './store/settings'
import Logger from './utils/logger'
import Storage from './utils/storage'
import iconOff from './assets/icon-off48.png'
import iconOn from './assets/icon-on48.png'
import './assets/icon16.png'
import './assets/icon48.png'
import './assets/icon128.png'

const enabled = {}

const setIcon = (tabId) => {
const path = enabled[tabId] ? iconOn : iconOff
chrome.pageAction.setIcon({ tabId, path })
}

const sendMessage = (tabId) => {
chrome.tabs.sendMessage(tabId, {
id: 'enabledChanged',
data: { enabled: enabled[tabId] }
})
}

chrome.pageAction.onClicked.addListener((tab) => {
Logger.log('chrome.pageAction.onClicked', tab)

enabled[tab.id] = !enabled[tab.id]
setIcon(tab.id)
sendMessage(tab.id)
})

chrome.runtime.onInstalled.addListener(async (details) => {
Logger.log('chrome.runtime.onInstalled', details)

const state = {
settings: defaults,
...(await Storage.get())
}
await Storage.set(state)
})

chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
Logger.log('chrome.runtime.onMessage', message, sender, sendResponse)

const { id } = message
const { tab } = sender
switch (id) {
case 'contentLoaded':
chrome.pageAction.show(tab.id)
setIcon(tab.id)
sendMessage(tab.id)
break
case 'controlButtonClicked':
enabled[tab.id] = !enabled[tab.id]
setIcon(tab.id)
sendMessage(tab.id)
break
case 'stateChanged':
chrome.tabs.query({}, (tabs) => {
tabs.forEach((tab) => {
chrome.tabs.sendMessage(tab.id, { id: 'stateChanged' })
})
})
break
}
})
;(() => {
Logger.log('background script loaded')
})()
Loading

0 comments on commit 96d95ce

Please sign in to comment.