A days OCD: Explore #Telugu words through Chrome Extension for AndhraBharati.com

A days OCD: Explore #Telugu words through Chrome Extension for AndhraBharati.com

begin

If you know a bit about Chrome extension you can create one on from the below. I may publish it as a proper extension soon. For now.

Background.js

begin code

/**
 * background.js
 * 
 * How to use this extension to explore Telugu Dictionaries
 * 
 * Go to AndhraBharati.com/dictionary
 * 
 * 1. Double click on any telugu word
 * 2. Right click and choose "Lookup T" (for Lookup Telugu)
 * 
 */


var menu_id="telugu_lookup_id"


function clicked(info, tab)
{
    console.log("Your menu is clicked")
    s = info.selectionText
    console.log("ST:" + s)
    console.log(info)
    console.log(tab)
    myNewUrl = "https://www.andhrabharati.com/dictionary/index.php?w="
    myNewUrl += encodeURIComponent(s)
    chrome.tabs.update(tab.id, {url: myNewUrl});
}


function createMyMenu()
{
    var title="Lookup T"
    var context = "selection"


    menuid = chrome.contextMenus.create(
                    {
                        "title": title, 
                        "contexts":[context],
                        "id":menu_id
                    }
               );
    //Register callback
    chrome.contextMenus.onClicked.addListener(clicked)
}


chrome.runtime.onInstalled.addListener(function() {
    console.log("Installing menu")
    createMyMenu()
    console.log("Installing menu done")
 }
);

end code

Manifest.json

begin code

{
    "name": "Explore Telugu Word",
    "version": "1.0",
    "description": "Explore any telugu word on a web page using Andhrabharati.com/dictionary",
    "manifest_version": 2,
    "background": {
        "scripts": ["background.js"],
        "persistent": false
    },
    "permissions": [
        "contextMenus",
        "tabs"
    ]
 
}


end code

要查看或添加评论,请登录

Satya Komatineni的更多文章

社区洞察

其他会员也浏览了