mrj / De-Clickbait news.com.au Headlines

// ==UserScript==
// @name         De-Clickbait news.com.au Headlines
// @updateURL    https://openuserjs.org/meta/mrj/De-Clickbait_news.com.au_Headlines.meta.js
// @namespace    https://openuserjs.org/users/mrj
// @version      1
// @description  news.com.au has made their article headings super-clickbaity. More information about an article is often hidden in article URLs. This script replaces headlines with ones derived from those URLs.
// @match        http*://www.news.com.au/
// @grant        none
// @license      MIT
// ==/UserScript==

document.querySelectorAll('a.storyblock_title_link[href*="/news-story/"]').forEach(function (storyLink) {
  var path = storyLink.pathname;
  var headingEnd = path.lastIndexOf('/news-story/');
  var headingStart = path.lastIndexOf('/', headingEnd-1) + 1;
  var heading = path.charAt(headingStart).toUpperCase() + path.slice(headingStart+1, headingEnd).replace(/-/g,' ');
  storyLink.innerText = heading;
});