Load external JS from bookmarklet?

前端 未结 4 1753
不知归路
不知归路 2020-12-02 08:23

How can I load an external JavaScript file using a bookmarklet? This would overcome the URL length limitations of IE and generally keep things cleaner.

4条回答
  •  旧巷少年郎
    2020-12-02 08:43

    2015 Update

    Content security policy will prevent this from working in many sites now. For example, the code below won't work on Facebook.

    2008 answer

    Use a bookmarklet that creates a script tag which includes your external JS.

    As a sample:

    javascript:(function(){document.body.appendChild(document.createElement('script')).src='** your external file URL here **';})();
    

提交回复
热议问题