gpt_chrome_autodrafter_v3/minimal_implementation_steps.md
2025-07-01 15:46:34 -07:00

2.1 KiB

Minimal Implementation Steps

What You Need to Do:

1. Add the Enhanced Extractor File

  • Copy enhanced_thread_extractor.js to your extension folder (same directory as content.js)

2. Update manifest.json

Add the new file to web_accessible_resources:

"web_accessible_resources": [
  {
    "resources": ["email_parser.js", "enhanced_thread_extractor.js"],
    "matches": ["https://mail.google.com/*"]
  }
]

3. Update content.js

Add this at the TOP of content.js (around line 10, after the color definitions):

// Load enhanced thread extractor
const script = document.createElement('script');
script.src = chrome.runtime.getURL('enhanced_thread_extractor.js');
script.onload = function() {
  console.log('Enhanced thread extractor loaded');
};
(document.head || document.documentElement).appendChild(script);

4. Comment Out Old Functions

In content.js, comment out or remove these functions (lines ~1000-1100):

  • function extractThreadId(context = 'current')
  • function getSelectedThreadIds()

Just add /* before the function and */ after it:

/* 
function extractThreadId(context = 'current') {
  // ... existing code ...
}
*/

/*
function getSelectedThreadIds() {
  return extractThreadId('selected');
}
*/

5. Reload Extension

  1. Go to chrome://extensions/
  2. Find your extension
  3. Click the refresh icon
  4. Test on Gmail

That's It! 🎉

The enhanced extractor provides the same function names (extractThreadId and getSelectedThreadIds), so your existing code will automatically use the enhanced versions.

What You Get:

  • 7+ extraction methods (vs current 4)
  • Automatic fallbacks
  • Better logging
  • Session history tracking
  • No breaking changes

Test It:

  1. Open Gmail
  2. Open DevTools Console (F12)
  3. Try selecting threads in inbox - you'll see detailed extraction logs
  4. Try opening a thread - you'll see which method found the ID

If Something Goes Wrong:

Simply uncomment the old functions and remove the script injection - takes 30 seconds to rollback.