最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to add user script js file as a Chrome extension? - Stack Overflow

programmeradmin4浏览0评论

I have been currently working on user scripts for Chrome that can function without the use of Tampermonkey. Today I added a third party extension (a userscript js) to the Chrome extensions:

// ==UserScript==
// @name       "job changer"
// @namespace  Marshmellows
// @version    0.1
// @description  Change 'Jobs' in stackoverflow to Hello!
// @match      /*
// @grant      none
// @run-at     document-start
// ==/UserScript==

document.addEventListener('DOMContentLoaded', function() {
    document.getElementById('nav-jobs').innerHTML = 'Hello!';
}, false);

I added this to the Chrome extensions by simply dragging the file inside (it worked fine).

I restarted Chrome and discovered that it had pletely blocked my js file extension. I can't seem to find a solution for this problem. I went on Chrome's forum and tried to find ways to create a .crx file. But because I am quite new to web development and the DOM, I feel like I need some guidance. Can anything be done?

I have been currently working on user scripts for Chrome that can function without the use of Tampermonkey. Today I added a third party extension (a userscript js) to the Chrome extensions:

// ==UserScript==
// @name       "job changer"
// @namespace  Marshmellows
// @version    0.1
// @description  Change 'Jobs' in stackoverflow to Hello!
// @match      http://stackoverflow./*
// @grant      none
// @run-at     document-start
// ==/UserScript==

document.addEventListener('DOMContentLoaded', function() {
    document.getElementById('nav-jobs').innerHTML = 'Hello!';
}, false);

I added this to the Chrome extensions by simply dragging the file inside (it worked fine).

I restarted Chrome and discovered that it had pletely blocked my js file extension. I can't seem to find a solution for this problem. I went on Chrome's forum and tried to find ways to create a .crx file. But because I am quite new to web development and the DOM, I feel like I need some guidance. Can anything be done?

Share Improve this question edited Nov 28, 2016 at 18:03 Brock Adams 93.7k23 gold badges241 silver badges305 bronze badges asked Nov 25, 2016 at 2:41 marshmellooooooosmarshmellooooooos 593 silver badges21 bronze badges 2
  • You might want to check the suggested solutions in this SO post and see what works for you. – Teyam Commented Nov 25, 2016 at 17:43
  • @Teyam, pretty sure those answers stopped working after, about, August 2014. Irregardless, it doesn't stop the script from getting auto-disabled; I just verified that. – Brock Adams Commented Nov 28, 2016 at 5:37
Add a ment  | 

1 Answer 1

Reset to default 6

As you discovered, although you can still install a plain userscript by dragging it to the chrome://extensions/ page, it will be automatically disabled when Chrome restarts. Google claims that this is to "protect" users from malicious extensions.

To keep your userscript from being auto disabled, you must pack it into an extension manually. See the steps at the "Controlling the Script and name" section of this answer.

Extensions installed this way will not be auto-disabled, but they will trigger a popup warning on every single start of Chrome!
Google refuses to provide developers any recourse to that popup. To avoid it, you must register your new extension in the Google Pay Store.

Unless you plan to graduate to extension development, or you just love needless hassle, it would be foolish to do this for a userscript. Just install Tampermonkey and enjoy how easy and powerful userscript development can be.

发布评论

评论列表(0)

  1. 暂无评论