# Pass data TO content script

**URL:** <https://discourse.joplinapp.org/t/pass-data-to-content-script/13615>\
**Category:** Plugins\
**Created:** [4 January 2021 19:51 UTC](https://discourse.joplinapp.org/t/pass-data-to-content-script/13615 "2021-01-04T19:51:32Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![ambrt](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/ambrt/32/4428_2.png) [@ambrt](https://discourse.joplinapp.org/u/ambrt)\
**Post date:** [11 January 2021 13:52 UTC](https://discourse.joplinapp.org/t/pass-data-to-content-script/13615/7 "2021-01-11T13:52:22Z")

</div>

I'm looking for doing MarkdownIt version of automatic Backlinks to notes - backlinks [plugin](https://discourse.joplinapp.org/t/insert-referencing-notes-backlinks-plugin/13632) (instead of manually like its now).

```auto
function plugin(md, _options) {
    console.log(_options)
    

    function render_footnote_block_open2(tokens, idx, options) {

        return `<div id="backref">back</div><a href="#" onclick="let cont='asdf';async function a(){cont=await webviewApi.executeCommand('getCont');webviewApi.executeCommand('getCont').then(res=>console.log(res));document.getElementById('backref').innerHTML=cont};a();">asdf</a>`
    //return `<div id="backref">back</div><a href="#" onclick="document.getElementById('backref').innerHTML='test manual';">asdf</a>`
        
      }
      

    md.renderer.rules.footnote_block_open2 = render_footnote_block_open2;
    

    function footnote_tail2(state) {
 

        token = new state.Token('footnote_block_open2', '', 1);
        state.tokens.push(token);
  }
  md.core.ruler.after('inline', 'footnote_tail2', footnote_tail2);

```

```auto
		await joplin.commands.register({
			name: 'getCont',
			label: 'returns backlinks html',
			execute: async () => {
				console.log("called getCont()");

                // Here i would create HTML and pass it to markdown
				return "<b> testing html from command</b>"
			},
		});

```

Its possible to do it with panel view instead of Markdown plugin,  
but that would clutter user interface.  
Just thinking out loud but maybe ContentScript could have access to `joplin.data` methods?

---

_[View the full topic](https://discourse.joplinapp.org/t/pass-data-to-content-script/13615)._
