Redirect IMDB Cast links to Mobile

Replaces all the links to view the cast of an IMDB title with the mobile version of the site because the mobile version has better formatting, but redirect back to desktop for the media gallery because that one is better

  1. // ==UserScript==
  2. // @name Redirect IMDB Cast links to Mobile
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Replaces all the links to view the cast of an IMDB title with the mobile version of the site because the mobile version has better formatting, but redirect back to desktop for the media gallery because that one is better
  6. // @author You
  7. // @match https://www.imdb.com/*
  8. // @match https://m.imdb.com/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=imdb.com
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. var links = document.querySelectorAll('a[href*="fullcredits/cast"]');
  17. links.forEach(function(thing) {thing.href = thing.href.replace("www","m")});
  18.  
  19. links = document.querySelectorAll('a[href*="mediaindex"]');
  20. links.forEach(function(thing) {thing.href = thing.href.replace("//m.","//www.")});
  21. })();