Created
September 7, 2012 08:47
-
-
Save keiya/3664427 to your computer and use it in GitHub Desktop.
ブラウザ閲覧中のタブ一覧をPHPに送って、HTMLで一覧が見れるやつ
This file contains hidden or 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
| // サーバ側 | |
| // touch dat.php && chmod 666 dat.php | |
| <?php | |
| if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
| $fp = fopen('dat.csv','w'); | |
| if ($fp === FALSE) { | |
| die(); | |
| } | |
| foreach ($_POST as $key => $post) { | |
| $list = array(htmlspecialchars($key),htmlspecialchars($post)); | |
| fputcsv($fp,$list); | |
| } | |
| header('Location:.'); | |
| } | |
| else { | |
| $fp = fopen('dat.csv','r'); | |
| if ($fp === FALSE) { | |
| die(); | |
| } | |
| $list = array(); | |
| while (($data = fgetcsv($fp,1000,",")) !== FALSE) { | |
| $list[] = $data; | |
| } | |
| if (isset ($_GET['json']) && $_GET['json'] == 1) { | |
| header('Content-type:application/json'); | |
| echo json_encode($list); | |
| } | |
| else { | |
| $html = ''; | |
| foreach ($list as $val) { | |
| $fragment = parse_url($val[1]); | |
| $html .= '<dt><a href="'.$val[1].'" target="blank">'.$val[0].'</a></dt><dd>'.$fragment['host'].'</dd>'; | |
| } | |
| ?> | |
| <!DOCTYPE html> | |
| <html> | |
| <head></head> | |
| <body> | |
| <dl> | |
| <?php echo $html; ?> | |
| </dl> | |
| <form action='.' method='post'> | |
| <input name='1' type='text' /> | |
| <input type='submit'> | |
| </form> | |
| </body> | |
| </html> | |
| <?php | |
| } | |
| } | |
| fclose($fp); |
This file contains hidden or 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
| // Firefoxアドオン側 | |
| exports.main = function() {}; | |
| var data = require("self").data; | |
| var request = require("request"); | |
| var widget = require("widget").Widget({ | |
| id: "mozilla-link", | |
| label: "Send tabs", | |
| contentURL: "http://www.mozilla.org/favicon.ico", | |
| onClick: listTabs | |
| }); | |
| function listTabs() { | |
| var tabs = require("tabs"); | |
| var str = ''; | |
| var sendtab = {}; | |
| for each (var tab in tabs) { | |
| sendtab[tab.title] = tab.url; | |
| } | |
| request.Request({ | |
| url : "http://web.missinglink.co.jp/clip/", | |
| content:sendtab, | |
| }).post(); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment