fork download
  1.  
  2. function OpenURL(Url){
  3. browser.tabs.create({"url": Url,"active":true });
  4. }
  5.  
  6. browser.contextMenus.create({
  7.  
  8. id: 'LinkLinker_Tab_001a',
  9.  
  10. title: '新しいタブ:"%s"', //%s は選択している文字列で置き換わる
  11.  
  12. contexts: ['selection'], //選択しているときのみメニューに表示される
  13.  
  14. onclick: (info, tab)=>{ //クリックされた際のアクション
  15. var T = null;
  16. var S = info.selectionText;
  17.  
  18. T =S.match(/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w-.\/?%&=]*)?/);
  19.  
  20. if(T){
  21. OpenURL(S);
  22. }else{
  23. S = ("http://"+S);
  24. T = S.match(/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w-.\/?%&=]*)?/);
  25. if(T){
  26. OpenURL(S);
  27. }else{
  28. alert("「"+info.selectionText+"」はURLではないようです。");
  29. }
  30. }
  31. }
  32.  
  33. });
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty