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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Redirect IMDB Cast links to Mobile
// @namespace    http://tampermonkey.net/
// @version      0.1
// @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
// @author       You
// @match        https://www.imdb.com/*
// @match        https://m.imdb.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=imdb.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var links = document.querySelectorAll('a[href*="fullcredits/cast"]');
    links.forEach(function(thing) {thing.href = thing.href.replace("www","m")});

    links = document.querySelectorAll('a[href*="mediaindex"]');
    links.forEach(function(thing) {thing.href = thing.href.replace("//m.","//www.")});
})();