Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>okay, it's actually very simple to implement. <strike>you just need to add to this a background.js file.</strike></p> <p>Here is the flow of the extension:</p> <ol> <li>the popup.js receives the input text</li> <li>the popup.js raises <strike>an event request</strike> a new tab request</li> <li><strike>the background.js listens to the event and gets data from the request</strike></li> <li><strike>the background.js then creates a new tab with the src as url+input</strike></li> </ol> <p>you're done, <strike>will you be willing for me to write this code?</strike></p> <hr> <p><strong>EDIT: The Code</strong></p> <hr> <p>The best part is, now you will not need to pass messages to background.js as per latest chrome extension docs the tab permission can be accessed from popups. The following code will take an input string in popup and will send the user in a new tab where the input string is searched on google. Most of the code is self explanatory, <strong>Lemme know if you're not able to work it out, i will send you the crx + source</strong></p> <p>manifest.json:</p> <pre><code>{ "name" : "Simple Search", "version" : "0.1", "manifest_version" : 2, "description" : "Simple Search Plugin", "browser_action": { "default_icon": { "19": "images/icon_48.png" }, "default_title": "Simple Search", "default_popup": "popup.html" }, "permissions" : [ "tabs" ], "content_security_policy": "script-src 'self' https://ajax.googleapis.com; object-src 'self'" } </code></pre> <p>popup.html</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style&gt; body{ font-family:"lucida grande",tahoma,verdana,arial,sans-serif; } &lt;/style&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="popup.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body style="width:300px;"&gt; &lt;center&gt; &lt;h1&gt;Simple Search&lt;/h1&gt; &lt;input type="text" id="q"&gt;&lt;/input&gt; &lt;input type="button" id="s" value="search"&gt; &lt;/center&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>popup.js</p> <pre><code>$(function() { $('#s').click(function() { var url = "https://www.google.com/search?q=" + $('#q').val(); chrome.tabs.create({url: url}); }); }); document.addEventListener('DOMContentLoaded'); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload