Skip to content

Instantly share code, notes, and snippets.

View Coande's full-sized avatar

Coande Coande

View GitHub Profile
@liuhao2050
liuhao2050 / images_bg_change.py
Last active November 6, 2021 05:41
A demo to change a picture's background use python
from PIL import Image
if __name__ == "__main__":
im = Image.open("mr.zhang.jpg")
x, y = im.size
for i in range(x):
for j in range(y):
r, g, b = im.getpixel((i,j))
if (20< r < 180) and (80< g < 250) and (180< b< 265):
r, g, b = 255, 255, 255
im.putpixel((i, j), (r, g, b))
@paulirish
paulirish / how-to-view-source-of-chrome-extension.md
Last active July 24, 2024 16:44
How to view-source of a Chrome extension

Option 1: Command-line download extension as zip and extract

extension_id=jifpbeccnghkjeaalbbjmodiffmgedin   # change this ID
curl -L -o "$extension_id.zip" "https://clients2.google.com/service/update2/crx?response=redirect&os=mac&arch=x86-64&nacl_arch=x86-64&prod=chromecrx&prodchannel=stable&prodversion=44.0.2403.130&x=id%3D$extension_id%26uc" 
unzip -d "$extension_id-source" "$extension_id.zip"

Thx to crxviewer for the magic download URL.

// Listens when new request
chrome.webRequest.onHeadersReceived.addListener(function(details) {
for (i = 0; i < details.responseHeaders.length; i++) {
if (isCSPHeader(details.responseHeaders[i].name.toUpperCase())) {
var csp = details.responseHeaders[i].value;
// append "https://mysite.com" to the authorized sites
csp = csp.replace('script-src', 'script-src https://mysite.com');
csp = csp.replace('style-src', 'style-src https://mysite.com');