Skip to content

Commit

Permalink
feat: add archiver and improve design
Browse files Browse the repository at this point in the history
  • Loading branch information
pistom committed Nov 11, 2020
1 parent 0ba70d1 commit 7de034c
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 21 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- [Ecosia](https://www.ecosia.org)
- [Yandex](https://www.yandex.ru)
- [OneSearch](https://www.onesearch.com/)
- [Baidu](http://www.baidu.com/) (partially)

Add an issue if you would like to use the extension with another search engine.

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"dependencies": {
"@material-ui/core": "^4.0.1",
"@material-ui/icons": "^4.0.1",
"archiver": "^5.0.2",
"chrome-storage-promise": "^0.1.0",
"react": "^17.0.0",
"react-dom": "^17.0.0",
Expand Down
13 changes: 8 additions & 5 deletions src/content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
background: rgba(255, 255, 255, .85);
padding: 0 8px;
min-width: 260px;
border: 1px solid rgba(0, 0, 0, .25);
border-radius: 2px;
border-radius: 4px;
box-sizing: border-box;
opacity: 0;
box-shadow: 5px 5px 1px rgba(80, 80, 128, 0.15);
}

.hohser_result_management:hover .hohser_actions {
Expand All @@ -59,6 +59,7 @@
text-align: center;
padding: 0;
margin: 0;
color: rgba(80, 80, 128, 0.6);
}

.hohser_actions_domain button {
Expand All @@ -72,11 +73,14 @@

.hohser_actions_domain button svg {
font-size: 1rem;
color: rgba(0,0,0,.54);
color: rgba(80, 80, 128, 0.6);
}

.hohser_actions_btns {
text-align: center;
button {
color: rgba(80, 80, 128, 0.6);
}
}

#hohser_domains_counter {
Expand Down Expand Up @@ -141,15 +145,14 @@
}

/* Baidu specific */
#wrapper_wrapper {
.hohser_result-baidu {
.MuiSvgIcon-root {
height: 20px;
width: 20px;
}
}

/* DuckDuckGo specific */

.super1:not(:hover) .result__snippet {
color: black!important;
}
Expand Down
12 changes: 2 additions & 10 deletions src/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,7 @@ function applyResultStyle (
result.classList.add("hohser_highlight");
result.style.backgroundColor = getRgbCss(domainColors[color], alpha);
result.style.transition = `.5s`;
if (searchEngine === "google") {
result.style.boxShadow = `0 0 0 5px ${getRgbCss(domainColors[color], alpha)}`;
}
if (searchEngine === "startpage") {
// On Startpage, use solid but lighter color
// since search results can overlap
const lightColor = domainColors[color].map((val: number) => val + (255 - val) * (1 - alpha));
result.style.backgroundColor = getRgbCss(lightColor);
}
result.style.boxShadow = `0 0 0 5px ${getRgbCss(domainColors[color], alpha)}`;
} else if (displayStyle === PARTIAL_HIDE) {
result.classList.add("hohser_partial_hide");
} else if (displayStyle === FULL_HIDE && (!options || !options?.showAll)) {
Expand Down Expand Up @@ -96,7 +88,7 @@ function processResult (r: Element, domainList: any, options: any, processResult
let displayStyle: DisplayStyle | null = null;
try {
const result = r as HTMLElement;
result.classList.add('hohser_result');
result.classList.add('hohser_result', 'hohser_result-' + searchEngine);
const domain = searchEngineConfig.resultUrlSelector &&
result.querySelector(
searchEngineConfig.resultUrlSelector
Expand Down
24 changes: 19 additions & 5 deletions src/utils/build.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
const path = require('path');
const ncp = require('ncp').ncp;
const source = path.resolve(__dirname, '../../build/firefox/static');
const destination = path.resolve(__dirname, '../../build/chrome/static');
const buildPatch = path.resolve(__dirname, '../../build/')
const firefoxStatic = buildPatch + '/firefox/static';
const chromeStatic = buildPatch + '/chrome/static';
const file_system = require('fs');
const archiver = require('archiver');
const manifest = require(buildPatch + '/firefox/manifest.json');

console.log('Copying builded files to Chrome extension directory...');
ncp(source, destination, function (err) {
ncp(firefoxStatic, chromeStatic, function (err) {
if (err) {
return console.error(err);
} else {
console.log('done!');
}
});

});

console.log('Creating zip packages...');
const extVersion = manifest['version'];
const browsers = ['firefox', 'chrome'];
browsers.forEach( browser => {
const output = file_system.createWriteStream(`${buildPatch}/hohser-${extVersion}_${browser}.zip`);
const archive = archiver('zip', {zlib: { level: 9 } });
archive.pipe(output);
archive.directory(`${buildPatch}/${browser}`, false);
archive.finalize();
});
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ archiver-utils@^2.1.0:
normalize-path "^3.0.0"
readable-stream "^2.0.0"

archiver@~5.0.2:
archiver@^5.0.2, archiver@~5.0.2:
version "5.0.2"
resolved "https://registry.yarnpkg.com/archiver/-/archiver-5.0.2.tgz#b2c435823499b1f46eb07aa18e7bcb332f6ca3fc"
integrity sha512-Tq3yV/T4wxBsD2Wign8W9VQKhaUxzzRmjEiSoOK0SLqPgDP/N1TKdYyBeIEu56T4I9iO4fKTTR0mN9NWkBA0sg==
Expand Down

0 comments on commit 7de034c

Please sign in to comment.