Created
November 9, 2013 08:24
-
-
Save odaillyjp/7383071 to your computer and use it in GitHub Desktop.
http://sandbox.onlinephpfunctions.com/ のテキストボックス内の文字に var_dump を挿入する Chrome の拡張。
全ファイル同じフォルダに突っ込んで、Chrome でアドオンとして読み込んで、テキストボックス内で文字を範囲選択してから右クリックして「var_dump を挿入」を選ぶだけ。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chrome.contextMenus.create({ | |
title: "var_dump を挿入", | |
contexts: ["selection"], | |
documentUrlPatterns: ["http://sandbox.onlinephpfunctions.com/"], | |
onclick: function() { | |
chrome.tabs.executeScript(null, {file: "content_script.js"}); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
function getSelectedArea(obj) { | |
var pos = new Object(); | |
pos.start = obj.selectionStart; | |
pos.end = obj.selectionEnd; | |
return pos; | |
} | |
function setValueTextBox(function_name, obj_name) { | |
var target = document.getElementsByName(obj_name)[0]; | |
var pos = getSelectedArea(target); | |
var textValue = target.value; | |
var selectedTextValue = textValue.slice(pos.start, pos.end); | |
var beforeTextValue = textValue.slice(0, pos.start); | |
var afterTextValue = textValue.slice(pos.end); | |
target.value = beforeTextValue + function_name + "(" + selectedTextValue + ")" + afterTextValue; | |
return true; | |
} | |
setValueTextBox("var_dump", "code"); | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"manifest_version": 2, | |
"name" : "add_var_dump", | |
"version" : "1.0", | |
"description" : "選択部分を var_dump 関数で囲う機能を追加します。", | |
"permissions" : ["contextMenus", "tabs", "http://sandbox.onlinephpfunctions.com/"], | |
"background": { | |
"scripts" : ["background.js"] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment