토론 » 개발

possible to combine two userscripts that operate in the same domain, but different match?

§
게시: 2019-11-08

possible to combine two userscripts that operate in the same domain, but different match?

Is it possible to consolidate two or more scripts into one? I'd like to make it easier for people to enable a collection of "features" without having a ton of scripts to maintain.

example: One script operations on www.domain.com/pageA/* the other on www.domain.com/pageB/*

woxxom관리자
§
게시: 2019-11-08

Combine @match or @include from both scripts and check location:

if (location.pathname.startsWith('/pageA')) {
  console.log('a');
} else {
  console.log('b');
}

답글 게시

답글을 게시하려면 로그인하세요.

长期地址
遇到问题?请前往 GitHub 提 Issues。