Skip to content

Instantly share code, notes, and snippets.

@jan-vandenberg
Created July 12, 2024 21:12
Show Gist options
  • Save jan-vandenberg/32d52498869197a2157da151df0d0497 to your computer and use it in GitHub Desktop.
Save jan-vandenberg/32d52498869197a2157da151df0d0497 to your computer and use it in GitHub Desktop.
javascript:(function(){
// Function to get the word count of the page
function getWordCount() {
var text = document.body.innerText || document.body.textContent;
var words = text.match(/\b\w+\b/g);
return words ? words.length : 0;
}
// Get the HTML title of the page
var title = document.title;
// Get the URL of the page
var url = window.location.href;
// Get the word count of the page
var wordCount = getWordCount();
// Get the current date
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth() + 1; // Months are zero-indexed
var day = today.getDate();
// Google Form URL with pre-filled data
var formUrl = 'https://docs.google.com/forms/d/e/USE_YOUR_OWN_UNIQUE_ID/viewform?usp=pp_url' +
'&entry.1028951525_year=' + encodeURIComponent(year) +
'&entry.1028951525_month=' + encodeURIComponent(month) +
'&entry.1028951525_day=' + encodeURIComponent(day) +
'&entry.1191252805=' + encodeURIComponent(title) +
'&entry.1659788503=' + encodeURIComponent(url) +
'&entry.2079472299=' + encodeURIComponent(wordCount);
// Redirect to the pre-filled Google Form
window.open(formUrl, '_blank');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment