Skip to content

Instantly share code, notes, and snippets.

@Haraldson
Last active March 10, 2017 13:20
Show Gist options
  • Save Haraldson/2c8cbf1b49fa1d2b7d87788323f40ea2 to your computer and use it in GitHub Desktop.
Save Haraldson/2c8cbf1b49fa1d2b7d87788323f40ea2 to your computer and use it in GitHub Desktop.
Couchsurfing: Show week days in Dashboard overview
// ==UserScript==
// @name Couchsurfing: Show week days in Dashboard overview
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Less cognitive load!
// @author Hein Haraldson Berg
// @match https://www.couchsurfing.com/dashboard
// @grant none
// ==/UserScript==
(function() {
'use strict';
const now = new Date();
const year = now.getFullYear();
let cardDetails = document.querySelectorAll('.mod-main .card .card-content > ul.mod-bulleted');
cardDetails.forEach((cardDetail) => {
let detailsListItem = cardDetail.querySelector('li:first-child');
let details = detailsListItem.innerText.split('(');
let dates = details[0].split('-');
dates.forEach((date, i) => {
dates[i] = new Date(`${date} ${year}`).toString().split(year)[0];
});
let meta = details.length > 1 ? ` (${details[1]}` : '';
detailsListItem.innerText = `${dates.join(' – ')}${meta}`;
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment