Skip to content

Commit

Permalink
fix(sources): fix haloruns previous record video and user links
Browse files Browse the repository at this point in the history
  • Loading branch information
fent committed Oct 31, 2018
1 parent debd0fd commit 97c493f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions background/sources/collections/haloruns.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ const RECORDS_PAGE = 'https://haloruns.com/records?recent';
const resolveLink = ($link) => {
return new URL($link.getAttribute('href'), RECORDS_PAGE).href;
};
const embedLink = ($link) => {
const $a = document.createElement('a');
$a.href = resolveLink($link);
$a.target = '_blank';
$a.textContent = $link.textContent;
return $a.outerHTML;
};

export default async () => {
const body = await util.ajax(RECORDS_PAGE);
Expand Down Expand Up @@ -56,8 +63,8 @@ export default async () => {
title: game + ' ' + difficulty + ' - ' + $level.textContent +
' (' + $newRecord.textContent.replace(/ /g, '') + ')',
timestamp: date.getTime(),
desc: 'Previous Record: ' + $previousRecord.outerHTML +
' by ' + $previousUser.outerHTML + '<br />' +
desc: 'Previous Record: ' + embedLink($previousRecord) +
' by ' + embedLink($previousUser) + '<br />' +
'Time Saved: ' + timeSaved,
game: { name: game },
});
Expand Down

0 comments on commit 97c493f

Please sign in to comment.