Pause/Mute HTML5 Audio/Video On Leaving Tab

Pause or mute HTML5 audio/video on leaving a tab and restore them back on returning.

< 腳本Pause/Mute HTML5 Audio/Video On Leaving Tab的回應

評論:正評 - 腳本一切正常

§
發表於:2017-12-13
編輯:2017-12-13

How to Make an Exeption

How can I exempt a website from this script,
so that the script does not apply to this page.

Example:
I want to listen to a radio station (music, news)
on one page in a background tab,
while I am looking at something else in the foreground tab;
the background tab here would have to be exempt from Your script,
while the script still remains valid for all other sites.

jcunews作者
§
發表於:2017-12-13

You can include an @exclude script metadata. e.g. if you want to exclude youtube.com, insert below line:

// @exclude     *://*.youtube.com/*

Insert it at line #8, which is after below line:

// @include     *://*/*
§
發表於:2017-12-13

Dear jcunews,

Very nice of You to respond so promptly.
That is what I thought, but I tried it earlier
with apparently the wrong site,
where what You said does not work.

Namely, @exclude works fine with
*://*.youtube.com/*
also fine with
*://*.cnn.com/*
etc,
but somehow
*://*.msnbc.com/*
does not work.

You can test it on :
http://www.msnbc.com/the-last-word/watch/doug-jones-triumphs-over-roy-moore-in-alabama-senate-election-1115292739644
or on
http://www.msnbc.com/brian-williams/watch/trump-tweets-congratulations-to-doug-jones-1115311171615

Using @exclude with
*://*msnbc.com*
or
*msnbc.com*
did not work either.

Any ideas ?

§
發表於:2017-12-14

OK,
I figured out what was wrong with the MSNBC player.

The MSNBC player works inside a frame,
whose address is different from MSNBC.com,
so to address (exempt in this case) You have to use
// @exclude *://*player.theplatform.com/*

§
發表於:2017-12-14

This user script is perfect.

jcunews作者
§
發表於:2017-12-14

Good to know it eventually worked out for you.

You may want to bookmark these for future reference.

For those @abcxyz fields:
https://wiki.greasespot.net/Metadata

For @include and @exclude:
https://wiki.greasespot.net/Include_and_exclude_rules

For @match:
https://developer.chrome.com/extensions/match_patterns

§
發表於:2017-12-14

Thanks !

Excellent resources.

發表回覆

登入以回復