Skip to content

Instantly share code, notes, and snippets.

@delowar-mtl
Last active May 3, 2023 04:21
Show Gist options
  • Save delowar-mtl/5de40c15975b3ed0dbadee7ce61d9faf to your computer and use it in GitHub Desktop.
Save delowar-mtl/5de40c15975b3ed0dbadee7ce61d9faf to your computer and use it in GitHub Desktop.

I used jquery. We will use jQuery Injector chrome extension to load jQuery.

Steps
var commits = $(".TimelineItem.TimelineItem--condensed:first-child").children(".TimelineItem-body").children("ol").children();
const date = new Date(); // get the current date
const day = date.getDate(); // get the day of the month
const monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
const month = monthNames[date.getMonth()]; // get the month name
const year = date.getFullYear(); // get the year

// Add ordinal suffix to day
let suffix;
switch (day) {
  case 1:
  case 21:
  case 31:
    suffix = 'st';
    break;
  case 2:
  case 22:
    suffix = 'nd';
    break;
  case 3:
  case 23:
    suffix = 'rd';
    break;
  default:
    suffix = 'th';
}

const formattedDate = `${day}${suffix} - ${month} ${year}`;


var activities = `Dear Sir,

Today's (${formattedDate}) activities are - 

`;
$.each(commits, function(index, commit) {
  let text = $(commit).children("div:first-child").children("p:first-child").children("a").html();
  let url = "https://github.com"+$(commit).children("div:first-child").children("p:first-child").children("a").attr("href");

    activities += (index + +1)+". "+text+" ["+url+"]\n"
});


const textarea = document.createElement('textarea');
  textarea.value = activities;
  
  // Add the textarea element to the DOM
  document.body.appendChild(textarea);

  // Select the contents of the textarea
  textarea.select();

  // Copy the selected text to the clipboard
  document.execCommand('copy');

  // Remove the textarea element from the DOM
  document.body.removeChild(textarea);
alert("Copied and ready to be pasted")

Expected output:

1. Profitability Report PDF Done https://github.com/magnetismtech/hr-lines/commit/aa85c6
2. Profitability Report PDF Done https://github.com/magnetismtech/hr-lines/commit/0321d0
3. not sure what did I mess https://github.com/magnetismtech/hr-lines/commit/41ec8809f7a
4. Expense Schedule Summation Added https://github.com/magnetismtech/hr-lines/commit/40e
5. Expense Invoices Delete https://github.com/magnetismtech/hr-lines/commit/5ea108484267

Then you can use chatgpgt to format this. Or you can improve the script.

Todo
  • Format for gmail [90% Done]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment