Skip to content

Commit

Permalink
Merge pull request #8 from OrionReed/hue-selectors
Browse files Browse the repository at this point in the history
Customisable colours based on selector matching
  • Loading branch information
OrionReed authored Mar 29, 2024
2 parents a714951 + 25e58ab commit 6d77824
Show file tree
Hide file tree
Showing 8 changed files with 433 additions and 230 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ A 3D DOM viewer for Firefox, Chrome, and Safari
## Install
Download the latest [release](https://github.com/OrionReed/dom3d/releases) and unzip the file.

<details>
<summary><b>Tiny Bookmarklet version</b></summary>
Simply prefix this code with `javascript:` and save it as a bookmark on Chrome or Firefox. This is a 1-1 equivelant to the full extension with the default configuration.

```js
(()=>{let e=t=>[...t.children].reduce((t,n)=>Math.max(t,e(n)),0)+1,t=e(document.body),n=(e,n=0,o=0)=>`hsl(${n}, 75%, ${Math.min(10+e*(1+60/t),90)+o}%)`,o=document.body;o.style.overflow="visible",o.style.transformStyle="preserve-3d",o.style.perspective=1e4;let r=window.innerWidth/2,i=window.innerHeight/2;o.style.perspectiveOrigin=o.style.transformOrigin=`${r}px ${i}px`,function e(t,o,r,i){for(let l=t.childNodes,s=l.length,d=0;d<s;d++){let s=l[d];if(1!==s.nodeType)continue;let f=n(o,190,-5);Object.assign(s.style,{transform:"translateZ(20px)",overflow:"visible",transformStyle:"preserve-3d",backgroundColor:f});let a=r,c=i;s.offsetParent===t&&(a+=t.offsetLeft,c+=t.offsetTop),e(s,o+1,a,c)}}(o,0,0,0),document.addEventListener("mousemove",e=>{let t=180*(1-e.clientY/window.innerHeight)-90,n=180*e.clientX/window.innerWidth-90;o.style.transform=`rotateX(${t}deg) rotateY(${n}deg)`})})();
```
</details>

**In Firefox**
1. Go to `about:debugging#/runtime/this-firefox`
2. Click "Load Temporary Addon"
Expand Down
12 changes: 12 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://biomejs.dev/schemas/1.6.3/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
}
}
37 changes: 23 additions & 14 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
const fs = require('fs-extra');
const path = require('path');
const fs = require("fs-extra");
const path = require("node:path");

const MANIFEST_COMMON = 'manifest.json';
const MANIFEST_COMMON = "manifest.json";

// Retrieve the browser name from command-line arguments
const browserName = process.argv[2];

// Validate the input argument
if (!browserName) {
console.error('Usage: node build.js <browserName>');
process.exit(1);
console.error("Usage: node build.js <browserName>");
process.exit(1);
}

// Define file paths based on the browser name
const commonManifestPath = path.join(__dirname, MANIFEST_COMMON);
const browserSpecificManifestPath = path.join(__dirname, `manifest-${browserName}.json`);
const outputPath = path.join(__dirname, 'dist', browserName);
const browserSpecificManifestPath = path.join(
__dirname,
`manifest-${browserName}.json`,
);
const outputPath = path.join(__dirname, "dist", browserName);

// Clear the dist/{browser} directory
fs.removeSync(outputPath);
Expand All @@ -24,18 +27,24 @@ fs.removeSync(outputPath);
fs.ensureDirSync(outputPath);

// Copy src to dist/{browser}
const srcPath = path.join(__dirname, 'src');
const srcPath = path.join(__dirname, "src");
fs.copySync(srcPath, outputPath);

// Read and parse the JSON files
const commonManifest = JSON.parse(fs.readFileSync(commonManifestPath, 'utf8'));
const browserSpecificManifest = JSON.parse(fs.readFileSync(browserSpecificManifestPath, 'utf8'));
const commonManifest = JSON.parse(fs.readFileSync(commonManifestPath, "utf8"));
const browserSpecificManifest = JSON.parse(
fs.readFileSync(browserSpecificManifestPath, "utf8"),
);

// Merge the two objects
const combinedManifest = { ...commonManifest, ...browserSpecificManifest };

// Write the combined JSON to the output file
const manifestOutputPath = path.join(outputPath, 'manifest.json');
fs.writeFileSync(manifestOutputPath, JSON.stringify(combinedManifest, null, 2), 'utf8');

console.log(` Build successful: ${browserName}`);
const manifestOutputPath = path.join(outputPath, "manifest.json");
fs.writeFileSync(
manifestOutputPath,
JSON.stringify(combinedManifest, null, 2),
"utf8",
);

console.log(` Build successful: ${browserName}`);
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"default_icon": {
"128": "assets/dom3d-128.png"
},
"default_title": "DOM3D"
"default_title": "dom3d"
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
},
"license": "GPL-3.0",
"devDependencies": {
"@biomejs/biome": "1.6.3",
"fs-extra": "^11.2.0",
"nodemon": "^3.1.0"
}
}
}
Loading

0 comments on commit 6d77824

Please sign in to comment.