项目作者: AdguardTeam

项目描述 :
Disable AMP userscript
高级语言: JavaScript
项目地址: git://github.com/AdguardTeam/DisableAMP.git
创建时间: 2019-08-23T08:32:42Z
项目社区:https://github.com/AdguardTeam/DisableAMP

开源协议:GNU Lesser General Public License v3.0

下载


Disable AMP by AdGuard

This is a very simple userscript that disables AMP pages on the Google search results page. Open Google search results on a mobile phone, click on the link marked as AMP. This link should be opened without AMP.

How to install

How to build

yarn install

Command Output Dir
yarn dev build/dev
yarn beta build/beta
yarn release build/release

Metadata

Placeholder - string in format [PLACEHOLDER_NAME] which will be replaced with metadata field.

Field or Metadata field - result string of metadata, e.g:

  1. // @description:en Userscript description text

How to change?

Remove, add or replace placeholders in file meta.template.js.

To specify the data for placeholders change the meta.settings.js.

  1. // meta.settings.js file structure
  2. const releaseChannels = {
  3. common: options,
  4. dev: options,
  5. beta: options,
  6. release: options,
  7. };

common - object with options which will be applied for all builds, you can redefine these options for specific release channel.

dev, beta, release - contains options for corresponding builds.

options

filename - the name of userscript metadata file, plugin creates new file in format [filename].meta.js.

postfix - string , default '', you can specify postfix for some fields (requires usePostfix:true flag for fieldOptions).

metadataTemplate - default metadata.template.js, relative path to template of metadata.

localesDir - default ./locales, relative path to directorty with locales.

fields - the object, where key is the name of placeholder and value is a string or fieldOptions object.

fieldOptions

If the data for field should be taken from translation, you need to use fieldOptions

  1. const releaseChannels = {
  2. ...
  3. dev: {
  4. filename: 'userscript-boilerplate',
  5. postfix: 'Dev',
  6. localesDir: './_locales',
  7. fields: {
  8. URL: 'http:example.org',
  9. // fieldOptions
  10. USERSCRIPT_NAME: {
  11. messageKey: 'some_name',
  12. metaName: 'name',
  13. usePostfix: true,
  14. }
  15. }
  16. },
  17. ...
  18. }

messageKey - string, key in translation file for this field.

metaName - string, name of field in output metadata file.

usePostfix - boolean, default false, use postfix for this field.


Translations

  • add needed locales codes to const LOCALES = ['en', 'ru']; array
  • run yarn locales:download to download translations
  • run yarn locales:upload to update current tranlations in Crowdin

Run tests

yarn test

How to add new one?

  • Add new file with tests in directory ./tests
  • Add import './path-to-your-file' in index.test.js

Run linter

yarn lint


TODO:

  • Fix AMP on Google images