Facebook 不触发刷新事件并且 Tampermonkey 不起作用?

Facebook doesn't fire refresh event and Tampermonkey won't work?

所以问题是在我登录 facebook 之前脚本一直在工作,然后为了启动脚本我必须手动刷新整个站点。

// ==UserScript==
// @name Open Test
// @version 1.0
// @description Test
// @include     http://facebook.com/*
// @include     http://*.facebook.com/*
// @include     https://facebook.com/*
// @include     https://*.facebook.com/*
// @include     http://facebook.com/*/*
// @include     http://*.facebook.com/*/*
// @include     https://facebook.com/*/*
// @include     https://*.facebook.com/*/*
// @include     http://facebook.com/*/*/*
// @include     http://*.facebook.com/*/*/*
// @include     https://facebook.com/*/*/*
// @include     https://*.facebook.com/*/*/*
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==

alert('Hello world!');

我不知道为什么 @include 不起作用,因为其中一些似乎必须与 facebook 登录页面匹配,无论如何你可以尝试使用 @match 来保持清晰,因为你的一些 @includes 正在做同样的事情,例如你正在添加:

// @include     https://facebook.com/*
// @include     https://facebook.com/*/*
// @include     https://facebook.com/*/*/*

但是第一个就足够了 // @include https://facebook.com/* 因为它已经匹配 https://facebook.com/example/path/other.

因此,正如我所说,为了保持清晰,您可以尝试使用 @match,如下所示:

// ==UserScript==
// @name Open Test
// @version 1.0
// @description Test
// @match *://www.facebook.com/*
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==

alert('Hello world!');

In this case @match *://www.facebook.com/*: Match any URL with both schemes (http and https) in www.facebook.com.

基本上 @includes@match 之间的区别是 @includes 允许正则表达式,但在您的情况下似乎不需要这样做。

在这里你可以看到更多关于how @match works.

的信息