首页 > 解决方案 > Tampermonkey @match not working when visit target link through redirection

问题描述

I'm trying to add a button to https://academic.microsoft.com/paper/*. But when I search on https://academic.microsoft.com/home and select any result to redirect to https://academic.microsoft.com/paper/*, the script won't run as expected. To trigger the user script, I need to refresh the website.

For example:

  1. Add a test user script
// ==UserScript==
// @name         Test Userscript
// @match        https://academic.microsoft.com/paper/*
// ==/UserScript==

(function() {
    'use strict';

    alert("Matched");
})();
  1. Search anything on https://academic.microsoft.com/home
  2. Press any result title to go to the detail page https://academic.microsoft.com/paper/*
  3. The user script won't run
  4. Refresh the website, the script runs

标签: javascriptgreasemonkeytampermonkey

解决方案


推荐阅读