Last active
April 5, 2024 10:15
-
-
Save rahulbansal16/1cb2cb119ffaa3c91a1847e07d0377ca to your computer and use it in GitHub Desktop.
Automating the Summary of Whatsapp bots
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install the extension https://chromewebstore.google.com/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo | |
Click on Icon and Dashboard from the Menu. | |
Click on New Script and paste the below code. | |
Navigate to web.whatsapp.com | |
You will see a summary button on every chat you open. | |
Click on the summary. | |
// ==UserScript== | |
// @name Whatsapp Chat Parsing | |
// @namespace http://tampermonkey.net/ | |
// @version 2024-04-02 | |
// @description Trying to take over the world! | |
// @author https://twitter.com/BansalRahul14 | |
// @match https://web.whatsapp.com/ | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=whatsapp.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
setInterval(function() { | |
if (!document.getElementById("summaryButton")) { | |
var summaryButton = document.createElement("button"); | |
summaryButton.innerHTML = "Summary"; | |
summaryButton.id = "summaryButton"; | |
summaryButton.style.color = "white"; | |
summaryButton.style.border = "2px solid white"; | |
summaryButton.style.cursor = "pointer"; | |
summaryButton.style.backgroundColor = "black"; // Button background color | |
summaryButton.style.padding = "10px 20px"; // Button padding | |
summaryButton.style.borderRadius = "5px"; // Rounded corners for the button | |
summaryButton.style.fontSize = "16px"; // Font size | |
summaryButton.style.fontWeight = "bold"; // Font weight | |
summaryButton.addEventListener('click', function() { | |
const elements = document.querySelectorAll('div.x3psx0u.xwib8y2.xkhd6sd.xrmvbpv'); | |
let chatContent = 'Summarise the below chat: \n --------------------- \n'; | |
elements.forEach(element => { | |
chatContent += element.innerText + ' '; | |
}); | |
// Copy to clipboard | |
navigator.clipboard.writeText(chatContent).then(function() { | |
alert("Text copied to clipboard. You can now paste it in ChatGPT for a summary."); | |
}, function(err) { | |
console.error('Could not copy text: ', err); | |
}); | |
}); | |
// Append the summary button to the second element with the specified class | |
var targetDivs = document.querySelectorAll("._ajv2._ajv1"); | |
if (targetDivs && targetDivs.length > 1) { | |
targetDivs[1].appendChild(summaryButton); | |
} | |
} | |
}, 1000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment