javascript - Google Chrome Extension: How to use an external script -


i trying make markdown preview tab forum use uses markdown in it's formatting not have way preview markdown like.

i want use page down markdown converter don't know how use files inside content script

here manifest.json

{ "name": "forum post previewer", "version": "0.1", "manifest_version":2, "description":"adds preview tab on post editor", "permissions": [     "activetab",     "*://*/*" ], "content_scripts": [     {         "js": ["previewtab.js"]     } ], 

}

and here previewtab.js

    // adding preview tab      var tabs = document.getelementsbyclassname("nav nav-tabs");      var list = document.createelement("li");      var tab = document.createelement("a");      tab.innerhtml = "preview";      tab.setattribute("data-toggle", "tab");      tab.setattribute("href", "#tab3");      list.appendchild(tab);      document.getelementbyid("post-editor").parentelement.firstelementchild.appendchild(list);                 var content = document.createelement("div");      content.setattribute("class", "tab-pane");      content.setattribute("id", "tab3");      var bar = document.createelement("div");      bar.setattribute("id", "wmd-button-bar");      var textarea = document.createelement("textarea");      textarea.setattribute("id", "wmd-input");      textarea.setattribute("class", "wmd-input");      var preview = document.createelement("div");      preview.setattribute("id", "wmd-preview");      preview.setattribute("class", "wmd-panel wmd-preview");      content.appendchild(bar);      content.appendchild(textarea);      content.appendchild(preview);      document.getelementbyid("post-editor").appendchild(content);                  // using converter      var converter = markdown.getsanitizingconverter();      var editor = new markdown.editor(converter);      editor.run();

right errors when using converter because not know markdown has come from.

can me find out how use external script in chrome extension

thanks

just add .js files extension , include them content scripts before yours, this:

"content_scripts": [     {         "js": ["markdown.converter", "markdown.editor", "markdown.sanitizer", "previewtab.js"]     } ], 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -