Skip to content

Instantly share code, notes, and snippets.

@Brontojoris
Last active December 14, 2021 04:01
Show Gist options
  • Save Brontojoris/ccff105d48ca1889f9dc734647a1284c to your computer and use it in GitHub Desktop.
Save Brontojoris/ccff105d48ca1889f9dc734647a1284c to your computer and use it in GitHub Desktop.
Proxyman - Set a Content Type icon
function onRequest(context, url, request) {
request.headers["Page"] = request.path;
return request;
}
function onResponse(context, url, request, response) {
if(response.statusCode !== 200){return response}
var contentIcon = "",
contentType = response.headers["Content-Type"];
if(contentType){contentType = contentType.toLowerCase()}else{return response}
switch (contentType) {
case 'text/html; charset=utf-8':
case 'text/html;charset=utf-8':
case 'image/x-icon':
contentIcon = "📃"
break;
case 'application/x-javascript;charset=utf-8':
case 'application/javascript; charset=utf-8':
case 'application/javascript;charset=utf-8':
case 'application/json; charset=utf-8':
case 'application/json;charset=UTF-8':
case 'application/json;charset=utf-8':
case 'text/javascript;charset=UTF-8':
case 'application/x-javascript':
case 'application/javascript':
case 'text/css;charset=utf-8':
case 'application/json':
case 'application/xml':
case 'text/css':
contentIcon = "🧾"
break;
case 'image/svg+xml':
case 'image/png':
case 'image/jpeg':
case 'image/gif':
contentIcon = "🖼"
break;
case 'application/octet-stream':
contentIcon = "🔠"
break;
default:
contentIcon = ""
}
response.headers["Icon"] = " "+contentIcon;
return response;
}
@Brontojoris
Copy link
Author

Brontojoris commented Jul 20, 2021

A script for Proxyman to display an icon for different content types.

Configure from: Proxyman > Scripting > Script List

image

To show these icons in the request window, open Proxyman > Tools > Custom Columns... and add a new one named "Icon"

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment