An open API service indexing awesome lists of open source software.

https://github.com/hchiam/lightweight-inspector

a lightweight mobile web inspector with no dependencies and just one code file to read
https://github.com/hchiam/lightweight-inspector

bookmark bookmarklet css html inspector js lightweight mobile no-dependencies single-file web

Last synced: 3 months ago
JSON representation

a lightweight mobile web inspector with no dependencies and just one code file to read

Awesome Lists containing this project

README

          

# lightweight-inspector [![GitHub release](https://img.shields.io/github/v/release/hchiam/lightweight-inspector)](https://github.com/hchiam/lightweight-inspector/releases)

Just one of the things I'm working on.

## 2 goals

1) enable minimally inspecting only a few things in js/css/html in a browser on a mobile device, and

2) make it easier to trust by making it easier to find and read [the whole code on GitHub](https://github.com/hchiam/lightweight-inspector/blob/main/script.js). (no deps)

example screenshot

## script.js code

## [bookmarklet](https://github.com/hchiam/learning-js/tree/main/bookmarklets#bookmarklets) to run the [script.js](https://github.com/hchiam/lightweight-inspector/blob/main/script.js)

_**MAKE SURE YOU UNDERSTAND THE CODE IN
[script.js](https://github.com/hchiam/lightweight-inspector/blob/main/script.js)
BEFORE YOU USE THIS OR ANY BOOKMARKLET CLAIMING TO USE IT!**_

### bookmarklet to automatically use the latest [version](https://github.com/hchiam/lightweight-inspector/releases)

(click to expand)

```js
javascript:(()=>{
fetch('https://api.github.com/repos/hchiam/lightweight-inspector/releases/latest')
.then(x=>x.json())
.then(x=>{
const src = `https://raw.githubusercontent.com/hchiam/lightweight-inspector/${x.tag_name}/script.js`;
try {
if (!document.addedLightweightInspectorSecuritypolicyviolationEventListener) {
document.addedLightweightInspectorSecuritypolicyviolationEventListener = true;
document.addEventListener('securitypolicyviolation', (e) => {
alert(`CSP blocking lightweight-inspector`);
});
}
fetch(src).then(x=>x.text()).then(x=>{eval(x);});
} catch(e) {
try {
const script = document.createElement('script');
script.src = src;
document.body.append(script);
} catch(e) {
alert(`couldn't start lightweight-inspector`);
}
}
});
})();
```

### bookmarklet example locked to [version](https://github.com/hchiam/lightweight-inspector/releases) **0.5.2**

to avoid automatic updates:

(click to expand)

```js
javascript:(()=>{
const src = 'https://raw.githubusercontent.com/hchiam/lightweight-inspector/0.5.2/script.js';
try {
if (!document.addedLightweightInspectorSecuritypolicyviolationEventListener) {
document.addedLightweightInspectorSecuritypolicyviolationEventListener = true;
document.addEventListener('securitypolicyviolation', (e) => {
alert(`CSP blocking lightweight-inspector`);
});
}
fetch(src).then(x=>x.text()).then(x=>{eval(x);});
} catch(e) {
try {
const script = document.createElement('script');
script.src = src;
document.body.append(script);
} catch(e) {
alert(`couldn't start lightweight-inspector`);
}
}
})();
```

## with [console-log-element](https://github.com/hchiam/console-log-element)

Firefox _on mobile_ seems to make it a little harder to run bookmarklets from your saved bookmarks. if you're using [console-log-element](https://github.com/hchiam/console-log-element) to run the above [bookmarklet](https://github.com/hchiam/learning-js/tree/main/bookmarklets#bookmarklets) in Firefox _on mobile_, here's a helpful code snippet to hide it when you don't need it anymore:

```js
$('#firefox-extension-console-log-element')?.remove();$('#script_firefox-extension-console-log-element')?.remove();
```

## local development

local development notes

(using [`bun`](https://github.com/hchiam/learning-bun))

this will automatically run :

```sh
bun dev
```

(Howard currently has automatically updated upon commit.)

and for Howard to deploy to and/or run this:

```sh
bun run deploy
```

if `bun run deploy` seems to have difficulty deploying to vercel via CLI, then a deploy webhook can instead be set up (to avoid having to change the github noreply email used in commits): (and then `bun run deploy` is no longer necessary)