Building a custom Google Chrome extension

19 Dec 2022

Goal would be to create an extension that triggers a Python script !projects/clipee, passing the current URL & page content as arguments.

Different logic would be applied depending on the URL, or based on a different parameter.

Extension to be triggered by a keyboard shortcut.

This will allow to collect data from the web much quicker & better than collecting links and scraping later.

ChatGPT provided the following guidance:




20 Dec 2022

This suggestion from ChatGPT could be interesting: triggering a shell script for every URL change.

chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
  if (changeInfo.url) {
    // If the URL of the tab has changed, trigger the shell script with the new URL as a parameter
    var scriptPath = '/path/to/your/shell/script';
    var url = changeInfo.url;
      { script: scriptPath, url: url },
      function(response) {
        console.log('Received response from native host: ', response);


An idea could be to implement this with logic to kick in only if a specific URL pattern is detected (eg '').
The shell script can trigger a Python script to save the page as HTML file in a dedicated folder.
This would allow to automatically save every HTML page from LinkedIn profiles visited, without doing anything.

Working extension

05 Jan 2023

Got some help and finally made it work.

This extension enables to save a HTML file in a given folder for any Linkedin profile visited:


    "name": "Save Linkedin Profiles",
    "version": "3.0",
    "manifest_version": 3,
    "description": "saves automatically Linkedin profiles visited to given folder as HTML file",
    "icons": { 
        "16": "icon.png",
        "32": "icon.png",
        "48": "icon.png",
        "128": "icon.png"

    "background": {
        "service_worker": "background.js"

    "host_permissions": ["<all_urls>"],



chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
html = request.html;
var dataUrl = 'data:text/html,' + encodeURIComponent(html);
filename = new URL(request.urlo)
filename = filename.href.replace(filename.origin,"").replace(/[^a-zA-Z0-9]/g, '_');{
    'url': dataUrl,
    'filename': "Linkedin/profiles/"+filename+".html",
    'saveAs': false

chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
    if (tab.status == 'complete' &&"chrome://")<0) {

urlo  = tab.url
    chrome.scripting.executeScript({ target: { tabId }, func:runner,args:[urlo]});

function runner(urlo){
exist = true

To implement this extension, have these files in a folder.
Then in Chrome:

  • go to chrome://extensions
  • activate Developer mode
  • click on Load unpacked
  • select the folder containing the files

It will be automatically triggered when visiting a Linkedin profile.

I have duplicated this extension to also save Linkedin Company profiles to a separate folder.