# HG changeset patch # User Andrew # Date 1653670573 14400 # Fri May 27 12:56:13 2022 -0400 # Node ID f0578558fa29ece1ce971683f2985e3e8cab3ba9 # Parent 0000000000000000000000000000000000000000 Current customizations. Map height, ratings, expand reviews. diff --git a/homepage.js b/homepage.js new file mode 100644 --- /dev/null +++ b/homepage.js @@ -0,0 +1,18 @@ +// ==UserScript== +// @name TrailLink Customizations +// @namespace http://tampermonkey.net/ +// @version 0.1 +// @description try to take over the world! +// @author You +// @match https://www.traillink.com/state/*/ +// @icon https://www.google.com/s2/favicons?sz=64&domain=traillink.com +// @grant none +// ==/UserScript== + +(function() { + 'use strict'; + + // Your code here... + var map = document.getElementById("state-map"); + map.style.height = "40rem"; +})(); \ No newline at end of file diff --git a/trailpage.js b/trailpage.js new file mode 100644 --- /dev/null +++ b/trailpage.js @@ -0,0 +1,40 @@ +// ==UserScript== +// @name TrailLink Trail Page +// @namespace http://tampermonkey.net/ +// @version 0.1 +// @description try to take over the world! +// @author You +// @match https://www.traillink.com/trail/*/ +// @icon https://www.google.com/s2/favicons?sz=64&domain=traillink.com +// @grant none +// ==/UserScript== + +(function() { + 'use strict'; + + // Your code here... + var accordionWrap = document.querySelector("#trail-detail-reviews .accordion-wrap"); + accordionWrap.classList.add("open"); + + var moreReviews = document.querySelectorAll("#trail-detail-reviews .accordion-item section"); + moreReviews.forEach(function(review) { + review.style.display = "block"; + }); + + var allReviews = document.querySelectorAll(".review-text p"); + allReviews.forEach(function(review) { + review.style.display = "unset"; + }); + + var ratedReviews = document.querySelectorAll(".review .stars [itemprop='ratingValue']"); + var cumulativeScore = 0; + ratedReviews.forEach(function(ratedReview) { + cumulativeScore += +ratedReview.content; + }); + var average = cumulativeScore/ratedReviews.length * 2; + console.log("Average rating = " + average); + + var rounded = (Math.round(average * 10) / 10).toFixed(1); + + document.querySelector(".hero-review .reviews").innerText = "" + rounded + ", " + document.querySelector(".hero-review .reviews").innerText +})(); \ No newline at end of file