From 5039d3024ad5c76d4a70542a9449ad06f6281b5a Mon Sep 17 00:00:00 2001 From: shiku Date: Sun, 20 Jan 2019 22:56:35 +0900 Subject: [PATCH] backup for linebreak --- background.js | 15 +++- manifest.json | 4 +- popup.html | 14 ++++ popup.js | 9 +++ preproc_en.js | 11 ++- preproc_ja.js | 204 ++++++-------------------------------------------- 6 files changed, 69 insertions(+), 188 deletions(-) diff --git a/background.js b/background.js index d1fdc48..11f2954 100644 --- a/background.js +++ b/background.js @@ -14,9 +14,15 @@ chrome.contextMenus.onClicked.addListener(function(info, tab){ chrome.storage.local.get(function(obj) { var summary_number = 3; var minimum_length = 5; - + var separator = [".","。"]; + var lang = "en"; summary_number = obj.summary_number; minimum_length = obj.minimum_length; + // group of separator is given by text split by " ". + // it is very bad hack... + separator = obj.separator.split(" "); + alert(separator); + lang = obj.lang; // not so good solution .... if(info.selectionText.length < 20){ if(tab.id>=0){ @@ -30,11 +36,16 @@ chrome.contextMenus.onClicked.addListener(function(info, tab){ //getinfo(); // summarize and push - summary = preproc_en(info.selectionText, summary_number, minimum_length); + if (lang == "ja"){ + summary = preproc_ja(info.selectionText, summary_number, minimum_length, separator); + }else{ + summary = preproc_en(info.selectionText, summary_number, minimum_length, separator); + } summary_alert = ""; for(var i=0; i=0){ chrome.tabs.sendMessage(tab.id, {"command":"fill", "summary":summary}); diff --git a/manifest.json b/manifest.json index 93bd8ce..16fea90 100644 --- a/manifest.json +++ b/manifest.json @@ -17,11 +17,11 @@ }, "content_scripts": [{ "matches": [""], - "js": ["jquery-3.3.1.min.js", "jquery.highlight-5.js", "imakita_body.js", "preproc_en.js", "content.js"] + "js": ["jquery-3.3.1.min.js", "jquery.highlight-5.js", "imakita_body.js", "preproc_en.js", "tiny_segmenter-0.2.js", "preproc_ja.js", "content.js"] }], "background": { - "scripts": ["jquery-3.3.1.min.js", "jquery.highlight-5.js", "imakita_body.js", "preproc_en.js", "background.js"], + "scripts": ["jquery-3.3.1.min.js", "jquery.highlight-5.js", "imakita_body.js", "preproc_en.js", "tiny_segmenter-0.2.js", "preproc_ja.js", "background.js"], "persistent": false } } diff --git a/popup.html b/popup.html index 65ae707..ae5f190 100644 --- a/popup.html +++ b/popup.html @@ -4,6 +4,20 @@

Imakita Summarizer

+ +

+ +