view pixiv-direct-external-link.user.js @ 104:93e21738b588

Run fix on whole body on start There's no guarantee the script loads before document.
author nanaya <me@nanaya.net>
date Sun, 25 Dec 2022 11:52:30 +0900
parents 9c8cde985caf
children 2c4470b73ad9
line wrap: on
line source

// ==UserScript==
// @name         pixiv direct external link
// @namespace    https://myconan.net
// @version      1.1.5
// @description  Make proper link on pixiv pages
// @author       nanaya
// @match        http://www.pixiv.net/*
// @grant        none
// @downloadURL  https://hg.myconan.net/ec-userscripts/raw-file/tip/pixiv-direct-external-link.user.js
// ==/UserScript==

/* global $ */
;(function () {
  'use strict'

  const fixLink = function (_i, el) {
    const $el = $(el)
    const url = decodeURIComponent($el.attr('href').replace(/^\/?jump.php\?/, ''))

    $el.attr('href', url)
  }

  $("[href^='jump.php?']").each(fixLink)
  $("[href^='/jump.php?']").each(fixLink)
}).call()