How to include Local htm pages in a Tampermonkey script?
Asked Answered
H

1

3

The script below works on a normal webpage, but how I can make it work on local .htm files too? (When opened in the Chrome browser)

// ==UserScript==
// @name            betterTwitter
// @version         0.5
// @namespace       http://www.h4xful.net/
// @description     Gets rid of the garbage on Twitter's side-panel.
// @include         http://twitter.com/*
// @include         https://twitter.com/*
// @include         file://C:/Users/*.htm
... ... 

The last line (@include file:...) doesn't work at all. The script doesn't fire for a sample page.

Howdoyoudo answered 23/12, 2015 at 13:44 Comment(0)
S
4

First, on Chrome's extensions setting page (chrome://extensions/), make sure Tampermonkey has access to file URLs:

File URL setting

Second, format the @include (or @match) with the correct number of slashes. It should almost always start with file:///.
For example:

// @include    file:///C:/Users/*.htm
Shewmaker answered 23/12, 2015 at 15:51 Comment(5)
Thanks Brock Adam, after the edit, the script appeared to available (the extension shows 1 working script on the page), but it is actually not working on local htm webpage, here is how i test the script:Howdoyoudo
open a local htm file with google chrome, the script does not work to remove and re-range the twitter webpage (only works on normal webpage), could you have a test on the script on local .htm ,thanks alotHowdoyoudo
@ivill, since Tampermonkey shows a working script, that's this question answered. You can put the line: console.log("Hello"); immediately after your script's metadata block. Then run the page and you'll see the message in the console. ... As for why your specific script doesn't run the way you expect on the local page, you did not include enough information for us to know, and it's beyond the scope of this question. Open a new question for that but only if you provide an MCVE in the new question.Shewmaker
Thanks again, the issue fixed, and i will start a new question.Howdoyoudo
@sanjihan, Probably, but I don't know for sure, nor the exact settings. I no longer have easy access to Safari. Suggest you look/ask on the Tampermonkey support forum.Shewmaker

© 2022 - 2024 — McMap. All rights reserved.