Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
3
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

@osamu2001

doit.imのchrome拡張の仕様がいまいちなのをどうにかする

doit.imのchrome拡張でコンテクストメニューから
文字列を選択せずタスクを追加すると

タスク名:ページのURL
タスクノート:
という残念なタスクが登録されてしまう。

タスク名:ページのタイトル
タスクノート:ページのURL
となるようにしたい。

right_click.js.old
var title_page =  _L("background_add_page_url");
var id_page = chrome.contextMenus.create({
    'title': title_page, 'contexts':['page'], 'onclick': function(OnClickData){
        var tmp = $.trim(OnClickData.pageUrl);
        if(tmp.length > 225){
            alert(_L('TASK_VALI_TITLE_TOO_LONG'));
            return;
        }else{
            var task = {
                uuid:makeUUID(),
                title : tmp,
                notes : '',
                start_at : null,//要拼凑
                completed : null,
                all_day : true,
                attribute: 'inbox'
            }
            postTask(task,function(t){
                alert(_L('Success'));
            });
        }
        //alert('page '+OnClickData.pageUrl);
    }
});

onclickのコールバックの引数にtabを追加するだけで、
titleを取得することができます。

right_click.js.new
var title_page =  _L("background_add_page_url");
var id_page = chrome.contextMenus.create({
    'title': title_page, 'contexts':['page'], 'onclick': function(OnClickData,tab){
        var tmp = $.trim(OnClickData.pageUrl);
        if(tmp.length > 225){
            alert(_L('TASK_VALI_TITLE_TOO_LONG'));
            return;
        }else{
            var task = {
                uuid:makeUUID(),
                title : tab.title,
                notes : tmp,
                start_at : null,//要拼凑
                completed : null,
                all_day : true,
                attribute: 'inbox'
            }
            postTask(task,function(t){
                alert(_L('Success'));
            });
        }
        //alert('page '+OnClickData.pageUrl);
    }
});
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
3
Help us understand the problem. What are the problem?