development

Chrome에 사용자 스크립트를 수동으로 추가

big-blog 2020. 6. 5. 08:07
반응형

Chrome에 사용자 스크립트를 수동으로 추가


사용자 스크립트를 "설치"하는 대신 웹에서 수동으로 추가하기위한 많은 자습서를 찾았습니다. 그들 모두 나에게 동일한 단계를 수행하도록 지시했습니다.

  • C : \ Users \ Blabla \ AppData \ Local \ Google \ Chrome \ User Data \ Default \ User Scripts 디렉토리를 만듭니다.
  • 사용자 스크립트가 포함 된 .js 파일을 거기에 배치하십시오
  • --enable-user-scripts 매개 변수를 사용하여 Chrome을 시작하십시오.

나는 그렇게했지만 내 데모 스크립트는 아무것도하지 않습니다.

// ==UserScript==
// @name           Test
// @description    Test
// @include        http://example.com/*
// @version        1.0
// ==/UserScript==

alert(0);

내가 무엇을 잘못하고 있지?


가장 좋은 방법은 Tampermonkey 확장 을 설치하는 것 입니다.

이를 통해 Greasemonkey 스크립트를 쉽게 설치하고 쉽게 관리 할 수 ​​있습니다. 또한 OpenUserJS , MonkeyGuts 등과 같은 사이트에서 직접 사용자 스크립트를 쉽게 설치할 수 있습니다 .

마지막으로 Chrome에 직접 GM 스크립트를 설치하여 얻을 수없는 모든 GM 기능을 잠금 해제합니다. 즉, Firefox의 GM이 할 수있는 것의 대부분은 Tampermonkey와 함께 사용할 수 있습니다.


그러나 GM 스크립트를 직접 설치하려면 요즘 Chrome 에서 쉽게 고통받을 수 있습니다 ...

Chrome 2014 년 8 월경 이후 :

파일을 확장 프로그램 페이지로 드래그 할 수 있으며 Chrome을 다시 시작할 때까지 작동 합니다. 그런 다음 영구적으로 비활성화됩니다. 자세한 내용 은 악성 확장 프로그램으로부터 Chrome 사용자를 "보호"하기 를 참조하십시오. 다시, Tampermonkey는 현명한 방법입니다. 또는 브라우저를 모두 Opera 또는 Firefox로 전환하십시오.

크롬 21 이상 :

Chrome은 확장 프로그램 설치 방식을 바꾸고 있습니다. 사용자 스크립트는 Chrome에서 확장 기능이지만 확장 프로그램입니다. Chrome 21부터는 사용자 스크립트 에서 링크 클릭 동작이 비활성화됩니다 . 사용자 스크립트를 설치하려면 **. user.js * 파일을 확장명 페이지 ( chrome://extensions주소 입력) 로 끌어 오십시오 .

이전 Chrome 버전 :

**. user.js * 파일을 Chrome 창으로 드래그하십시오. 또는 Greasemonkey 스크립트 링크를 클릭하십시오.

설치 경고가 나타납니다.
초기 경고

계속을 클릭하십시오 .


확인 대화 상자가 나타납니다.
확인 대화 상자

추가를 클릭 하십시오 .


노트:

  1. 이 방법으로 설치된 스크립트는 Greasemonkey (Firefox) 스크립트 또는 Tampermonkey 스크립트와 비교하여 제한이 있습니다. 참조 크로스 브라우저 사용자 스크립트, 크롬 섹션을 .

스크립트 및 이름 제어 :

기본적으로 Chrome은 확장 폴더 1에 스크립트 를 암호화 이름과 버전 번호로 설치합니다. 이 폴더 트리 아래에 스크립트를 수동으로 추가하려고하면 다음에 Chrome을 다시 시작할 때 스크립트가 지워집니다.

디렉토리와 파일 이름을보다 의미있는 것으로 제어하려면 다음을 수행하십시오.

  1. Chrome에서 일반적으로 확장 프로그램을 찾지 않는 편리한 디렉토리를 만듭니다 . 예를 들어, Create : C:\MyChromeScripts\입니다.

  2. 각 스크립트마다 고유 한 서브 디렉토리를 작성하십시오. 예를 들면 다음과 같습니다 HelloWorld.

  3. 해당 서브 디렉토리에서 스크립트 파일을 작성하거나 복사하십시오. 예를 들어,이 질문의 코드를 다음과 같이 저장하십시오 HelloWorld.user.js.

  4. 또한 해당 서브 디렉토리에 매니페스트 파일을 작성해야하며 이름은 다음과 같아야합니다 manifest.json.

    이 예에서는 다음을 포함해야합니다.

    {
        "manifest_version": 2,
        "content_scripts": [ {
            "exclude_globs":    [  ],
            "include_globs":    [ "*" ],
            "js":               [ "HelloWorld.user.js" ],
            "matches":          [   "https://stackoverflow.com/*",
                                    "https://stackoverflow.com/*"
                                ],
            "run_at": "document_end"
        } ],
        "converted_from_user_script": true,
        "description":  "My first sensibly named script!",
        "name":         "Hello World",
        "version":      "1"
    }
    

    manifest.json파일은 자동으로 사용자 스크립트가 설치되어있는 크롬에 의한 메타 블록에서 생성됩니다. 의 값 @include@exclude메타 규칙에 저장 include_globs하고 exclude_globs, @match(권장)에 저장되어있는 matches목록입니다. 지원되는 방법"converted_from_user_script": true 을 사용하려면 필수 입니다.GM_*

  5. 이제 Chrome 확장 프로그램 관리자 (URL = chrome : // extensions / )에서 "개발자 모드"를 확장하십시오 .

  6. Click the Load unpacked extension... button.

  7. For the folder, paste in the folder for your script, In this example it is: C:\MyChromeScripts\HelloWorld.

  8. Your script is now installed, and operational!

  9. If you make any changes to the script source, hit the Reload link for them to take effect:

    새로 고침 링크




1 The folder defaults to:

Windows XP:
  Chrome  : %AppData%\..\Local Settings\Application Data\Google\Chrome\User Data\Default\Extensions\
  Chromium: %AppData%\..\Local Settings\Application Data\Chromium\User Data\Default\Extensions\

Windows Vista/7/8:
  Chrome  : %LocalAppData%\Google\Chrome\User Data\Default\Extensions\
  Chromium: %LocalAppData%\Chromium\User Data\Default\Extensions\

Linux:
  Chrome  : ~/.config/google-chrome/Default/Extensions/
  Chromium: ~/.config/chromium/Default/Extensions/

Mac OS X:
  Chrome  : ~/Library/Application Support/Google/Chrome/Default/Extensions/
  Chromium: ~/Library/Application Support/Chromium/Default/Extensions/

Although you can change it by running Chrome with the --user-data-dir= option.


Update 2016: seems to be working again.

Update August 2014: No longer works as of recent Chrome versions.


Yeah, the new state of affairs sucks. Fortunately it's not so hard as the other answers imply.

  1. Browse in Chrome to chrome://extensions
  2. Drag the .user.js file into that page.

Voila. You can also drag files from the downloads footer bar to the extensions tab.

Chrome will automatically create a manifest.json file in the extensions directory that Brock documented.

<3 Freedom.


This parameter is is working for me:

--enable-easy-off-store-extension-install

Do the following:

  1. Right click on your "Chrome" icon.
  2. Choose properties
  3. At the end of your target line, place these parameters: --enable-easy-off-store-extension-install
  4. It should look like: chrome.exe --enable-easy-off-store-extension-install
  5. Start Chrome by double-clicking on the icon

Share and install userscript with one-click

To make auto-install (but mannually confirm), You can make gist (gist.github.com) with <filename>.user.js filename to get on-click installation when you click on Raw and get this page:

설치 페이지

How to do this ?

  1. Name your gist <filename>.user.js, write your code and click on "Create".
    요점에 파일 만들기

  2. In the gist page, click on Raw to get installation page (first screen).
    원시 버튼

  3. Check the code and install it.

참고URL : https://stackoverflow.com/questions/5258989/manually-adding-a-userscript-to-google-chrome

반응형