-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f3c11a2
Showing
46 changed files
with
3,399 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
YOUTUBE_KEY=YOUR_KEY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es2021": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:react/recommended" | ||
], | ||
"rules": { | ||
"no-useless-escape": "off", | ||
"react/jsx-uses-react": "off", | ||
"react/react-in-jsx-scope": "off", | ||
"no-var": "error" | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 12, | ||
"sourceType": "module" | ||
}, | ||
"globals": { | ||
"$": "readonly", | ||
"chrome": "readonly", | ||
"ga": "readonly", | ||
"process": "readonly" | ||
}, | ||
"settings": { | ||
"react": { | ||
"version": "detect" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
node_modules | ||
searcher | ||
searcher.zip | ||
.env | ||
.vs | ||
package-lock.json | ||
src/js/*.js | ||
src/js/*.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@babel/preset-react", | ||
{ | ||
"runtime": "automatic" | ||
} | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const clean = require('./clean'); | ||
const copy = require('./copy'); | ||
const bundleCSS = require('./bundle-css'); | ||
const updateVariables = require('./update-variables'); | ||
const zip = require('./zip'); | ||
|
||
var args = process.argv.slice(2); | ||
var buildType = getParameter(args, 'buildType'); | ||
if (buildType == '') buildType = 'test'; | ||
|
||
function getParameter(args, key) { | ||
var value = ''; | ||
args.forEach(function (v, i, a) { | ||
var keyValue = v.split('='); | ||
if (keyValue == undefined || keyValue.length < 2) | ||
return; | ||
if (key == keyValue[0]) | ||
value = keyValue[1]; | ||
}); | ||
return value; | ||
} | ||
|
||
async function build() { | ||
await clean(buildType); | ||
await copy(); | ||
await bundleCSS(); | ||
await updateVariables(); | ||
zip(buildType); | ||
} | ||
|
||
build(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const fs = require('fs-extra'); | ||
const less = require('less'); | ||
|
||
var cssDir = 'searcher/css'; | ||
var files = [`${cssDir}/sfd`, `${cssDir}/settings`]; | ||
|
||
async function bundleCSS() { | ||
var allFiles = await fs.readdir(cssDir); | ||
for (var i = 0; i < files.length; i++) { | ||
var v = files[i]; | ||
var input = await fs.readFile(`${v}.less`, { encoding: 'utf8' }); | ||
var output = await less.render(input, { filename: `${v}.less` }); | ||
await fs.outputFile(`${v}.css`, output.css, { encoding: 'utf8' }); | ||
} | ||
for (var i = 0; i < allFiles.length; i++) { | ||
await fs.remove(`${cssDir}/${allFiles[i]}`); | ||
} | ||
} | ||
|
||
module.exports = bundleCSS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const fs = require('fs-extra'); | ||
|
||
async function clean(buildType) { | ||
await fs.remove('searcher'); | ||
if (buildType == 'prod') | ||
await fs.remove('searcher.zip'); | ||
} | ||
|
||
module.exports = clean; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const fs = require('fs-extra'); | ||
|
||
async function copy() { | ||
await fs.copy('src', 'searcher'); | ||
} | ||
|
||
module.exports = copy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const fs = require('fs-extra'); | ||
|
||
async function updateVariables() { | ||
var manifest = await fs.readFile('searcher/manifest.json', 'utf8'); | ||
var manifest = manifest.replace(/VERSION/g, process.env.npm_package_version); | ||
await fs.writeFile('searcher/manifest.json', manifest, 'utf8'); | ||
} | ||
|
||
module.exports = updateVariables; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const zipFolder = require('zip-folder'); | ||
|
||
function zip(buildType) { | ||
if (buildType == 'prod') | ||
zipFolder('searcher', 'searcher.zip', function (err) { | ||
if (err) | ||
console.log(err); | ||
}); | ||
} | ||
|
||
module.exports = zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "searcher-for-discogs", | ||
"version": "8.1.0", | ||
"description": "Allows to listen to tracks on Discogs by clicking on it.", | ||
"scripts": { | ||
"build": "node build/build.js buildType=test", | ||
"build-webpack": "webpack --mode=development && npm run build", | ||
"release-webpack": "webpack --mode=production && npm run release", | ||
"release": "node build/build.js buildType=prod" | ||
}, | ||
"author": "Dmitry Sergienko", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@babel/cli": "^7.17.10", | ||
"@babel/core": "^7.18.0", | ||
"@babel/preset-react": "^7.17.12", | ||
"babel-loader": "^8.2.5", | ||
"dotenv": "^16.0.1", | ||
"dotenv-webpack": "^7.1.0", | ||
"eslint": "^8.16.0", | ||
"eslint-plugin-react": "^7.30.0", | ||
"eslint-webpack-plugin": "^3.1.1", | ||
"fs-extra": "^10.0.1", | ||
"less": "^4.1.2", | ||
"react": "^18.1.0", | ||
"react-dom": "^18.1.0", | ||
"webpack": "^5.72.1", | ||
"webpack-cli": "^4.9.2", | ||
"zip-folder": "^1.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
chrome.runtime.onMessage.addListener( | ||
function (request, sender, sendResponse) { | ||
if (request.method == "getQueryResult") { | ||
var headers = {}; | ||
if (request.contentType != undefined) | ||
Object.assign(headers, { "Content-type": request.contentType }); | ||
if (request.auth != undefined) | ||
Object.assign(headers, { "Authorization": request.auth }); | ||
|
||
fetch(request.url, { | ||
method: request.type, | ||
headers: headers, | ||
body: request.data, | ||
referrer: request.referrer | ||
}) | ||
.then(function (response) { | ||
if (response.status == 204) | ||
return; | ||
else | ||
return response.text(); | ||
}).then(function (response) { | ||
if (response == undefined) | ||
return; | ||
|
||
if (response.error) { | ||
sendResponse({ | ||
success: false, | ||
error: { | ||
status: response.error.code, | ||
message: response.error.message | ||
} | ||
}); | ||
} else { | ||
sendResponse({ success: true, result: response }); | ||
} | ||
}); | ||
|
||
return true; | ||
} | ||
}); |
Oops, something went wrong.