Skip to content

Commit

Permalink
Merge branch 'master' into firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
tamanobi authored Jul 31, 2018
2 parents 8ab32f3 + 711cc92 commit 24d051b
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 3 deletions.
10 changes: 10 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
jobs:
build:
docker:
- image: circleci/node:10.7.0
working_directory: ~/app
steps:
- checkout
- run: yarn install
- run: yarn build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
release/dist/
.DS_Store
yarn-error.log
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# Ku-nya
Ku-nya is Chrome Extension for pixiv lovers. It picks up illustrations on the pixiv ranking randomly and displays them on your new tab.


## Build

```bash
yarn install
yarn build
```
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"devDependencies": {
"@types/axios": "0.14.0",
"@types/chrome": "^0.0.70",
"@types/webpack": "4.4.0",
"prettier": "^1.13.4",
"ts-loader": "4.3.0",
Expand Down
13 changes: 10 additions & 3 deletions release/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@
"name": "Ku-nya",
"version": "1.0.1",
"manifest_version": 2,
"description": "Ku-nya picks up illustrations on the pixiv ranking randomly and displays them on your new tab. Enjoy your pixiv life!",
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"description":
"Ku-nya picks up illustrations on the pixiv ranking randomly and displays them on your new tab. Enjoy your pixiv life!",
"content_security_policy":
"script-src 'self' 'unsafe-eval'; object-src 'self'",
"icons": {},
"chrome_url_overrides": {
"newtab": "newTab.html"
},
"browser_action": {
"default_popup": "popup.html"
},
"permissions": ["https://www.pixiv.net/"]
"permissions": [
"webRequest",
"webRequestBlocking",
"https://www.pixiv.net/",
"https://i.pximg.net/"
]
}
29 changes: 29 additions & 0 deletions src/lib/requestModifier.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const refererValue = 'https://www.pixiv.net/'
const refererTarget = 'https://i.pximg.net/*'

/** Modifies request Referer HTTP header */
chrome.webRequest.onBeforeSendHeaders.addListener(
details => {
let refererFound = false

for (const n in details.requestHeaders) {
refererFound = details.requestHeaders[n].name.toLowerCase() == 'referer'

if (refererFound) {
// Rewrite Referer header
details.requestHeaders[n].value = refererValue
break
}
}

if (!refererFound) {
// If no referer header is set, set one
details.requestHeaders.push({ name: 'Referer', value: refererValue })
}
return { requestHeaders: details.requestHeaders }
},
{
urls: [refererTarget],
},
['requestHeaders', 'blocking'],
)
1 change: 1 addition & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { h, render } from 'preact'
import App from './components/App'
import './lib/requestModifier'
import { getOptions } from './lib/options'

document.addEventListener('DOMContentLoaded', async event => {
Expand Down
16 changes: 16 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
dependencies:
axios "*"

"@types/chrome@^0.0.70":
version "0.0.70"
resolved "https://registry.yarnpkg.com/@types/chrome/-/chrome-0.0.70.tgz#634bfa4aff89d00e8c88f6c37b26663e8d7a220e"
dependencies:
"@types/filesystem" "*"

"@types/filesystem@*":
version "0.0.28"
resolved "https://registry.yarnpkg.com/@types/filesystem/-/filesystem-0.0.28.tgz#3fd7735830f2c7413cb5ac45780bc45904697b0e"
dependencies:
"@types/filewriter" "*"

"@types/filewriter@*":
version "0.0.28"
resolved "https://registry.yarnpkg.com/@types/filewriter/-/filewriter-0.0.28.tgz#c054e8af4d9dd75db4e63abc76f885168714d4b3"

"@types/node@*":
version "8.0.47"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.47.tgz#968e596f91acd59069054558a00708c445ca30c2"
Expand Down

0 comments on commit 24d051b

Please sign in to comment.