Skip to content

Commit

Permalink
almost done with v8
Browse files Browse the repository at this point in the history
  • Loading branch information
Sans3108 committed Sep 17, 2024
1 parent 1dbb923 commit ddf2d1b
Show file tree
Hide file tree
Showing 28 changed files with 2,833 additions and 735 deletions.
8 changes: 4 additions & 4 deletions Privacy Policy.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Privacy Policy for AniList to AniWave
# Privacy Policy for AniList Watcher

## Introduction

I, Sans, am committed to maintaining the trust and confidence of all users of my AniList to AniWave browser extension. I want you to know that AniList to AniWave is not in the business of selling, renting or trading any personal information with other entities.
I, Sans, am committed to maintaining the trust and confidence of all users of my AniList Watcher browser extension. I want you to know that AniList Watcher is not in the business of selling, renting or trading any personal information with other entities.

In this Privacy Policy, I provide detailed information on when and why I do not collect your personal information, how it would be used if it were collected, the limited conditions under which it may be disclosed to others and how it would be kept secure.

## Information That I Collect

AniList to AniWave does not collect or store any personal information.
AniList Watcher does not collect or store any personal information.

## Use of Your Information

Expand All @@ -22,4 +22,4 @@ If I make a change to this policy that, in my sole discretion, is material, I wi

## Contact Me

If you have any questions about this policy or about how I handle your personal information, please contact me over on the Discord platform (sans._.) or via email (sansy3108@gmail.com).
If you have any questions about this policy or about how I handle your personal information, please contact me on Discord [`sans._.`](https://discord.com/users/366536353418182657).
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Simply adds a button to anilist anime pages that searches up the anime as best as it can on aniwave.
Simply adds a button to anilist anime & manga pages that searches up the media as best as it can on whatever site you want.

Currently supports

Yes, I'm lazy, how did you know?

Expand Down
122 changes: 97 additions & 25 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,98 @@
console.time('build');

const { exec } = require('child_process');
const { existsSync, rmSync } = require('fs');
const { copy } = require('fs-extra');
const glob = require('glob');
const path = require('path');
const util = require('util');

const execAsync = util.promisify(exec);
if (existsSync('out')) rmSync('out', { recursive: true, force: true });

copy('src', 'out/extension').then(() => {
execAsync('tsc -p config/tsconfig.json').then(() => {
let tsFiles = glob.sync('out/extension/**/*.ts');
tsFiles.forEach(tsFile => {
let jsFile = path.normalize(path.join('out', 'js', path.relative('out/extension', tsFile))).replace(/\.ts$/, '.js');
if (existsSync(jsFile)) {
rmSync(tsFile, { force: true });
copy(jsFile, tsFile.replace(/\.ts$/, '.js'));
}
});

console.timeEnd('build');
});
import { exec } from 'child_process';
import CleanCSS from 'clean-css';
import { existsSync, rmSync } from 'fs';
import { copy, remove } from 'fs-extra';
import { readFile, writeFile } from 'fs/promises';
import { glob } from 'glob';
import { minify as HtmlMinify } from 'html-minifier-terser';
import { join, normalize, relative } from 'path';
import { minify } from 'terser';
import { promisify } from 'util';
import manifest from './src/manifest.json' assert { type: 'json' };

const execAsync = promisify(exec);

async function build() {
console.time(`- ${manifest.name} v${manifest.version} was built and minified in`);

// Removing "out" if exists
if (existsSync('out')) {
rmSync('out', { recursive: true, force: true });
console.log(`- Removed "out" folder`);
}

// Copying everything from "src" to "out/extension" and compiling TS
await Promise.all([
copy('src', 'out/extension').then(() => console.log(`- Copied contents of "src" to "out/extension"`)),
execAsync('tsc -p config/tsconfig.json').then(() => console.log(`- Compiled TypeScript`))
]);

// Replacing TS files from "out/extension" with files from "out/js"
// Also minifying everying
const tsFiles = glob.sync('out/extension/**/*.ts');
const cssFiles = glob.sync('out/extension/**/*.css');
const htmlFiles = glob.sync('out/extension/**/*.html');

await Promise.all([
...tsFiles.map(async tsFile => {
if (tsFile.endsWith('global.d.ts')) return;

const jsFile = normalize(join('out', 'js', relative('out/extension', tsFile))).replace(/\.ts$/, '.js');

// Read the JS file
const data = await readFile(jsFile, { encoding: 'utf8' });

// Minimize
const result = await minify(data);
if (!result.code) throw new Error(`Failed to minify ${jsFile}`);

// Write the minified code to the new file
await writeFile(tsFile.replace(/\.ts$/, '.js'), result.code);
console.log(`- Written (minified) ${tsFile.replace(/\.ts$/, '.js')}`);
}),
...cssFiles.map(async cssFile => {
// Read the CSS file
const data = await readFile(cssFile, { encoding: 'utf8' });

// Minimize
const result = new CleanCSS().minify(data).styles;

// Write the minified CSS to the same file
await writeFile(cssFile, result);
console.log(`- Written (minified) ${cssFile}`);
}),
...htmlFiles.map(async htmlFile => {
// Read the HTML file
const data = await readFile(htmlFile, { encoding: 'utf8' });

// Minimize
const result = await HtmlMinify(data, { collapseWhitespace: true, minifyCSS: true, minifyJS: true });

// Write the minified HTML to the same file
await writeFile(htmlFile, result);
console.log(`- Written (minified) ${htmlFile}`);
}),
// Removing "out/extension/**/*.ts"
...tsFiles.map(tsFile => remove(tsFile).then(() => console.log(`- Removed ${tsFile}`)))
]);

// Removing "out/js"
await remove('out/js').then(() => console.log(`- Removed "out/js" folder`));

// Copy all files from "out/extension" to "out"
await copy('out/extension', 'out', { overwrite: true }).then(() => console.log(`- Moved everything from "out/extension" to "out"`));

// Remove the "out/extension" folder
await remove('out/extension').then(() => console.log(`- Removed "out/extenson"`));

console.log();
console.timeEnd(`- ${manifest.name} v${manifest.version} was built and minified in`);
}

build().catch(e => {
if (e.stdout) {
console.log(e.stdout);
} else {
console.log(e);
}
});
4 changes: 2 additions & 2 deletions config/nodemon.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"watch": ["src"],
"watch": ["src", "build.js"],
"ext": "*",
"exec": "node build.js"
"exec": "cls && node --disable-warning=ExperimentalWarning build.js"
}
4 changes: 2 additions & 2 deletions config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "ES2015",
"target": "ES2017",
"moduleResolution": "node",
"resolveJsonModule": true,
"outDir": "../out/js",
Expand All @@ -20,7 +20,7 @@
"skipDefaultLibCheck": true,
"skipLibCheck": true,
"sourceMap": false,
"lib": ["ES2016", "DOM"]
"lib": ["ES2017", "DOM"]
},
"include": ["../src/**/*.ts"],
"exclude": ["node_modules"]
Expand Down
25 changes: 17 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
{
"name": "anilist-to-aniwave",
"version": "7.0.0",
"description": "Adds a button on AniList anime pages that searches the anime on AniWave.",
"name": "anilist-watcher",
"version": "8.0.0",
"description": "Adds a button on AniList anime and manga pages to quickly open media on popular streaming and reading sites.",
"scripts": {
"watch": "nodemon --config config/nodemon.json",
"build": "node build.js"
"build": "node build.js --disable-warning ExperimentalWarning"
},
"keywords": [],
"author": "sans._.",
"license": "ISC",
"type": "module",
"devDependencies": {
"@types/chrome": "^0.0.246",
"nodemon": "^3.0.1"
"@types/clean-css": "^4.2.11",
"@types/fs-extra": "^11.0.4",
"@types/html-minifier-terser": "^7.0.2",
"@types/node": "20.14.8",
"nodemon": "^3.1.4"
},
"dependencies": {
"fs-extra": "^11.1.1",
"glob": "^10.3.10",
"typescript": "^5.2.2"
"clean-css": "^5.3.3",
"fs-extra": "^11.2.0",
"glob": "^10.4.5",
"html-minifier-terser": "^7.2.0",
"htmlparser2": "^9.1.0",
"terser": "^5.32.0",
"typescript": "^5.6.2"
}
}
Loading

0 comments on commit ddf2d1b

Please sign in to comment.