Tampermonkey - 匹配默认开始页面

时间:2017-01-24 08:42:54

标签: javascript tampermonkey

我尝试删除Chrome开头页面上最后看到的8个图块。 您知道,如果您启动Chrome,则会显示该页面。

但由于根本没有网址,我不知道我必须在@match上输入什么内容。 我已尝试// @match *,但脚本未执行。

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        *
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    setInterval(function(){
        var box = document.getElementById("mv-tiles");
        box.remove();
    },10
    );
})();

1 个答案:

答案 0 :(得分:1)

使用@include代替@match

此外,可以通过转到控制台并运行window.location.href

来获取URL

我试过这个并且有效:

// @include      http*://*chrome/newtab*

也许不要在那里使用一个区间,因为一旦元素不存在它就会继续抛出错误。

我会用这样的东西:

injectStyles('#mv-single {display: none;}');

function injectStyles (styles) {
    var style       = document.createElement('style');
    style.type      = 'text/css';
    style.innerHTML = styles;
    document.head.appendChild(style);
}
相关问题