使用Chrome 35及更高版本启用非PlayStore UserScript [英] Enable a non-PlayStore UserScript with Chrome 35 and above

查看:174
本文介绍了使用Chrome 35及更高版本启用非PlayStore UserScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自谷歌浏览器版本35开始,在Google PlayStore之外安装的任何扩展程序的执行被阻止,无法通过扩展菜单启用。



两年前删除了非商店脚本的自动安装,但下载脚本并执行拖放操作。放在扩展菜单上仍然允许安装,所以仍然可以为Google的Chrome创建和共享脚本。但现在一切都被锁定了。


  • 是否可以手动为独立脚本添加权限?

  • 有没有其他解决方案?



我知道这个限制不适用于 dev canary 发行频道,但是这些脚本目的在于使用由具有足够知识的用户知道他们在做什么,而不强迫他们更改浏览器。原生支持支持在Chrome上非常不稳定(即使现在完全锁定),所以没有第三方插件(即:Tampermonkey)的解决方案更好

谢谢

解决方案

编辑:我验证此解决方案,什么帮助我特别在这个问题上。 更为丰富的答案是 user2428118提供的解决方法列表 。即使他们没有解决我的具体问题,他们应该考虑。



我终于可以找到我的问题的答案感谢 yoz 发布的链接,事实是您仍然可以启用与PlayStore无关的脚本 ,没有任何第三方插件,但你会看到:使用TamperMonkey可能会更好(即使它可能意味着适应性小一点,但它更容易200%)。

解决方案是以开发人员模式导入解压后的用户脚本



逐步解释




  1. 创建用户脚本 myscript.user.js 通常为


  2. 将其包含在目录中并创建一个名为 manifest.json 的文件。你会得到这个结构(可以压缩分发):


    myscript /




  3. manifest.json

  4. myscript.user.js



  5. manifest.json 是一个需要在开发人员中将您的脚本作为Chrome扩展导入的文件。它描述了你的用户脚本。这里是相关的文档,但是我们的最低代码
    $ b


      {
    manifest_version:2,
    版本:1.0,
    name:MyScript,
    content_scripts:[
    {
    js:[myscript.user.js]] ,
    matches:[http://domain.com/]
    }
    ]
    }


  6. 既然您的目录中有您的用户脚本和manifest.json,您可以将它作为解压后的扩展程序(Chrome重新启动后会打包一个)。要做到这一点,只需选中开发者模式,然后选择加载解压后的扩展...。导航到在第2步创建的目录并选择它:这就是全部。

  7. ://i.stack.imgur.com/X81yU.pngalt =加载解压后的扩展名>



    优点




    • 本地解决方案

    • 如果您在Chrome上开发脚本(显然这不是我的情况:P) b $ b
    • 您的脚本现在被视为真实扩展名。


    缺点




    • 哦,上帝......我错过了一键安装:即使用户只需要完成第4步,仍然很痛苦。

    • 由于用户必须启用开发者模式,因此看起来不那么专业

    • 由于Google Chrome的脚本必须打包,因此不再是跨浏览器的发行版一种特殊的方式

    • 原始目录不能在不破坏脚本的情况下移动(重新)

    • 打开询问您是否确定要使用开发人员模式



    结论



    我喜欢用户脚本在Chrome上本机支持的方式:每个第三方插件都有一些小的变体(即:数据或xhr处理)。但缺点是对许多重要的(特别是最后两个)......即使以本地方式启用非PlayStore脚本也是可能的,但我建议将脚本改编为一个插件,如TamperMonkey 。毕竟,Chrome是一个例外,因为每个其他浏览器都需要一个插件,现在这些插件是唯一的方法。



    我仍然感到有点失望,所以如果有人碰巧找到一个更好的解决方案(仍然希望有一些白名单)我很乐意提供一些赏金。



    编辑:请注意 user2428118提供了其他有趣解决方法的列表。即使他们没有解决我的特殊问题,他们应该考虑。



    编辑:清单固定


    Since the version 35 of Google Chrome, the execution of any extension installed outside of the Google's PlayStore is blocked and cannot be enabled from the extensions menu.

    The auto-installation of non-store scripts was removed two years ago but downloading the script and performing a drag & drop on the extensions menu still allowed the installation, so it was still possible to create and share scripts for Google's Chrome. But now everything is locked.

    • Is it possible to manually add permissions to your independant scripts ?
    • Is it possible to white-list a personnal website ?
    • Is there any other solution ?

    I know that this restriction does not apply for dev and canary release channels but the scripts are purposed to be used by users with enough knowledge to know what they do, without forcing them to change their browser. The native support support is rather interresting on Chrome (even if completly locked now), so a solution without a third party plugin (ie : Tampermonkey) is better.

    Thank you

    解决方案

    EDIT : I validate this solution because it's what helped me particularly on this problem. A much richer answer is the list of workarounds submited by user2428118. Even if they did not solved my specific problem, they should be considered.

    I finally could find an answer to my question thanks to the link posted by yoz, and the fact is that you can still enable a script unrelated to the PlayStore, without any third party plug-in, but as you'll see : it might be better to use TamperMonkey (even if it might imply little adaptations, it's 200% easier).

    The solution is to import the unpacked user-script in developer mode.

    Step By Step Explanation

    1. Create your user script myscript.user.js as usually

    2. Include it in a directory and create a file named manifest.json. You'll get this structure (can be zipped for distribution) :

      myscript/

      • manifest.json
      • myscript.user.js

    3. The manifest.json is a file required to import your script as a Chrome extension in developer. It describes your user script. Here is the related documentation, but the minimal code for our purpose is :

       {
           "manifest_version":2,
           "version":"1.0",
           "name": "MyScript",
           "content_scripts": [
               {
                   "js": ["myscript.user.js"],
                   "matches": ["http://domain.com/"]
               }
           ]
       }
      

    4. Now that you have your directory with your user script and manifest.json, you can import it as an unpacked extension (a packed one will be disabled after Chrome's restart). To achieve this, simply check the "developer mode" and choose "Load Unpacked Extension...". Navigate to the directory created at step 2 and select it : that's "all".

    Pros

    • Native solution
    • Natural for you if your developing your script on Chrome (obviously this wasn't my case :P)
    • Your script is now treated like a "real" extension.

    Cons

    • Oh, god... I'm missing the one-click install : even if the user only has to achieve the step 4 it's still a pain.
    • Looks less "professional" because the user has to enable the developer mode
    • No longer "cross-browser" distribution since the Google Chrome's script has to be packed in a special way
    • The original directory cannot be (re)moved without breaking the script
    • A warning will be triggered every single time Chrome is opened to ask if you are sure that you want to use developer mode

    Conclusion

    I liked the way user-scripts had native support on Chrome : every third party plugin has some small variations (ie : datas or xhr handling). But the cons are to numerous and to important (especially the two last ones)... Even if enabling a non-PlayStore script is possible in a native way, it became such a pain that I recommend to adapt the script for a plugin such as TamperMonkey. After all, Chrome was an exception since every other browser require a plugin, now these plugins are the only way.

    I still feel a bit disappointed, so if anyone happens to find a better solution (still hoping for some white-lists) I would enjoy to offer some bounty.

    EDIT : Please note that user2428118 provided a list of other interesting workarounds. Even if they did not solved my specifif problem, they should be considered.

    EDIT : manifest fixed

    这篇关于使用Chrome 35及更高版本启用非PlayStore UserScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆