Skip to content

Commit

Permalink
2.15.5
Browse files Browse the repository at this point in the history
  • Loading branch information
garywill committed Nov 13, 2022
1 parent f4c2162 commit b051123
Show file tree
Hide file tree
Showing 16 changed files with 864 additions and 468 deletions.
46 changes: 31 additions & 15 deletions src/addon-popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
<script type='text/javascript' src='js/mtm.js'></script>
<script type='text/javascript' src='i_scripts.js'></script>
<script type='text/javascript' src='lzutf8.js'></script>
<script type='text/javascript' src='ajax.js'></script>
<script type='text/javascript' src='js/checku.js'></script>
<link rel='stylesheet' type='text/css' href='i_layout.css'></link>

<link rel='stylesheet' type='text/css' href='addon.css'></link>
Expand All @@ -61,11 +63,12 @@
<span class="header-nav-span">

<a>
<span class='lang lang-zh'>大术专搜</span><span class='lang lang-en'>Big Search</span> </a>
<span class='lang lang-zh'>大术专搜</span><span class='lang lang-en'>Big Search</span> 🔍
</a>

</span>
<span id="newver" style="display: none;" >
<a id="newver_link" target="_blank" >
<a id="newver_link" target="_blank" title="">
</a>
</span>
<span id="curver" ></span>
Expand Down Expand Up @@ -166,7 +169,7 @@
</span>


<button class="general_btn btns_copypaste" id="openhist" class="openhist_hide" >
<button class="general_btn btns_copypaste btns_copypaste_right" id="openhist" class="openhist_hide" >
<span class="span_copypaste_cont">
<span class="span_copypaste"><span class='lang lang-zh'>历史</span><span class='lang lang-en'>History</span></span>
</span>
Expand Down Expand Up @@ -228,7 +231,7 @@

<div id="div_search_permi" style="display:none; " >
<button id="btn_search_permi">
<span class='lang lang-zh'>读取浏览器内的搜索引擎</span><span class='lang lang-en'>Read browser-installed search engines</span> </button>
<span class='lang lang-zh'>开启此功能</span><span class='lang lang-en'>Enable this feature</span> </button>
</div>

<div id="engines_cont">
Expand Down Expand Up @@ -360,7 +363,7 @@ <h3><span class='lang lang-zh'>使用说明</span><span class='lang lang-en'>Usa


<li>
快捷键
快捷键(可能需自行修改)
<ul>
<li>唤出界面。Firefox: <code>Ctrl+Alt+S</code> | Chrome及其他:<code>Ctrl+Shift+S</code></li>
<li>将选择文本设定为搜索词(然后再使用唤出界面)。Firefox: <code>Ctrl+Alt+D</code> | Chrome及其他:<code>Ctrl+Shift+D</code></li>
Expand All @@ -376,15 +379,6 @@ <h3><span class='lang lang-zh'>使用说明</span><span class='lang lang-en'>Usa
<p>大术专搜 当然<b>不只是</b>一个简单的搜索请求发送器。可以访问源代码页面,以了解其一些<b>“独门特技”</b></p>



<h4>老用户FAQ</h4>

<p><strong>Q: Chrome系的浏览器中,选择文本后点击右键菜单没反应,还要点击一下工具栏按钮才打开界面</strong></p>

<p>A: 这是<a target="_blank" href="https://stackoverflow.com/questions/54189283/chrome-extension-open-popup-from-contentscript-file#comment95207111_54189283">仅Chrome内核浏览器有的缺陷</a>。请在选择了文本后,使用按键组合<code>Ctrl+Shift+D</code>然后<code>Ctrl+Shift+S</code>来作为暂时的快捷操作</p>



</span>

<span class="lang lang-en">
Expand All @@ -406,7 +400,7 @@ <h4>老用户FAQ</h4>


<li>
Keyboard shortcut
Keyboard shortcuts (may need changing manually )
<ul>
<li>Open popup. Firefox: <code>Ctrl+Alt+S</code> | Chrome &amp; others:<code>Ctrl+Shift+S</code></li>
<li>Set selected text as search term (then use open popup). Firefox: <code>Ctrl+Alt+D</code> | Chrome &amp; others:<code>Ctrl+Shift+D</code></li>
Expand All @@ -427,6 +421,28 @@ <h4>老用户FAQ</h4>
</span>
</div>

<div class="lang lang-zh">
<h3>老用户FAQ</h3>

<div style="text-align: left;">
<p><strong>Q: Chrome系的浏览器中,选择文本后点击右键菜单没反应,还要点击一下工具栏按钮才打开界面</strong></p>

<p>A: 这是<a target="_blank" href="https://stackoverflow.com/questions/54189283/chrome-extension-open-popup-from-contentscript-file#comment95207111_54189283">仅Chrome内核浏览器有的缺陷</a>。请在选择了文本后,使用按键组合<code>Ctrl+Shift+D</code>然后<code>Ctrl+Shift+S</code>(可能需自行修改)来作为暂时的快捷操作</p>
</div>
</div>
<div class="lang lang-en">
<h3>FAQ</h3>

<div style="text-align: left;">
<p><strong>Q: I selected text and used context menu, it won't automatically show popup until I click toolbar button (on some browsers like Chrome)</strong></p>

<p>A: It's because of <a target="_blank" href="https://stackoverflow.com/questions/54189283/chrome-extension-open-popup-from-contentscript-file#comment95207111_54189283">defect of Chrome browser engine</a>. Please use key combination <code>Ctrl+Shift+D</code> then <code>Ctrl+Shift+S</code> (you may want to modify them) as workaround</p>
</div>
</div>





</div>
<div class="btm_dialog" id="btn_donate_dialog" style="display:none;" >
Expand Down
153 changes: 78 additions & 75 deletions src/ajax.js
Original file line number Diff line number Diff line change
@@ -1,106 +1,109 @@
const ajax = _ajax_ ;
const keyword = _keyword_ ;

const before_start = 100;
var slow = 10;
async function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

async function start_go()
async function ajax_execute(ajax, keyword)
{
if ( typeof(ajax) === "string" )
await doInput(ajax, true);
else if ( Array.isArray(ajax) )
console.debug("ajax_execute()");
const before_start = 100;
var slow = 10;
async function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

async function start_go()
{
for (var i=0; i<ajax.length; i++)
if ( typeof(ajax) === "string" )
await doInput(ajax, true);
else if ( Array.isArray(ajax) )
{
ajax_arr_ele = ajax[i];
await sleep(slow * 10);
if ( typeof(ajax_arr_ele) === "string" )
for (var i=0; i<ajax.length; i++)
{
var web_element = document.querySelectorAll(ajax_arr_ele)[0];
if ( web_element.tagName == "TEXTAREA" )
ajax_arr_ele = ajax[i];
await sleep(slow * 10);
if ( typeof(ajax_arr_ele) === "string" )
{
await doInput(ajax_arr_ele, i==ajax.length-1);
}
else if ( web_element.tagName == "INPUT" )
{
if ( web_element.getAttribute("type") === null ||
["", "text", "search", "number", "tel", "email", "url", "password", "range", "date", "datetime-local", "time" , "week", "datetime", "hidden"]
.includes( web_element.getAttribute("type").toLowerCase() )
)
var web_element = document.querySelectorAll(ajax_arr_ele)[0];
if ( web_element.tagName == "TEXTAREA" )
{
await doInput(ajax_arr_ele, i==ajax.length-1);
}
else if (web_element.getAttribute("type").toLowerCase() == "radio")
else if ( web_element.tagName == "INPUT" )
{
web_element.checked="checked";
if ( web_element.getAttribute("type") === null ||
["", "text", "search", "number", "tel", "email", "url", "password", "range", "date", "datetime-local", "time" , "week", "datetime", "hidden"]
.includes( web_element.getAttribute("type").toLowerCase() )
)
{
await doInput(ajax_arr_ele, i==ajax.length-1);
}
else if (web_element.getAttribute("type").toLowerCase() == "radio")
{
web_element.checked="checked";
}
else if (["submit", "button", "reset"]
.includes( web_element.getAttribute("type").toLowerCase() )
)
{
web_element.click();
}
// TODO checkbox image file
}
else if (["submit", "button", "reset"]
.includes( web_element.getAttribute("type").toLowerCase() )
)
else if ( web_element.tagName == "BUTTON" )
{
web_element.click();
}
// TODO checkbox image file
}
else if ( web_element.tagName == "BUTTON" )
else if ( typeof(ajax_arr_ele) === "number" )
{
web_element.click();
await sleep(ajax_arr_ele);
}
}
else if ( typeof(ajax_arr_ele) === "number" )
{
await sleep(ajax_arr_ele);
}
}
}
}
async function doInput(queryStr, pressEnter=true)
{

var web_inputbox;

await sleep(slow * 5);
web_inputbox = document.querySelectorAll(queryStr)[0];
web_inputbox.focus();


await sleep(slow * 2);
web_inputbox = document.querySelectorAll(queryStr)[0];
web_inputbox.dispatchEvent ( new Event( "input", { bubbles:true } ) );

await sleep(slow * 2);
web_inputbox = document.querySelectorAll(queryStr)[0];
web_inputbox.dispatchEvent ( new Event( "change", { bubbles:true } ) );

await sleep(slow * 5);
web_inputbox = document.querySelectorAll(queryStr)[0];
web_inputbox.value = keyword ;

await sleep(slow * 2);
web_inputbox = document.querySelectorAll(queryStr)[0];
web_inputbox.dispatchEvent ( new Event( "input", { bubbles:true } ) );

await sleep(slow * 2);
web_inputbox = document.querySelectorAll(queryStr)[0];
web_inputbox.dispatchEvent ( new Event( "change", { bubbles:true } ) );

if (pressEnter)
async function doInput(queryStr, pressEnter=true)
{

var web_inputbox;

await sleep(slow * 5);
web_inputbox = document.querySelectorAll(queryStr)[0];
web_inputbox.dispatchEvent ( new KeyboardEvent( "keypress", { key: "Enter", keyCode: 13, bubbles: true } ) );
web_inputbox.focus();


await sleep(slow * 2);
web_inputbox = document.querySelectorAll(queryStr)[0];
web_inputbox.dispatchEvent ( new Event( "input", { bubbles:true } ) );

await sleep(slow * 2);
web_inputbox = document.querySelectorAll(queryStr)[0];
web_inputbox.dispatchEvent ( new Event( "change", { bubbles:true } ) );

await sleep(slow * 5);
web_inputbox = document.querySelectorAll(queryStr)[0];
web_inputbox.dispatchEvent ( new KeyboardEvent( "keydown", { key: "Enter", keyCode: 13, bubbles: true } ) );
web_inputbox.value = keyword ;

await sleep(slow * 2);
web_inputbox = document.querySelectorAll(queryStr)[0];
web_inputbox.dispatchEvent ( new Event( "input", { bubbles:true } ) );

await sleep(slow * 1);
await sleep(slow * 2);
web_inputbox = document.querySelectorAll(queryStr)[0];
web_inputbox.dispatchEvent ( new KeyboardEvent( "keyup", { key: "Enter", keyCode: 13, bubbles: true } ) );
web_inputbox.dispatchEvent ( new Event( "change", { bubbles:true } ) );

if (pressEnter)
{
await sleep(slow * 5);
web_inputbox = document.querySelectorAll(queryStr)[0];
web_inputbox.dispatchEvent ( new KeyboardEvent( "keypress", { key: "Enter", keyCode: 13, bubbles: true } ) );

await sleep(slow * 5);
web_inputbox = document.querySelectorAll(queryStr)[0];
web_inputbox.dispatchEvent ( new KeyboardEvent( "keydown", { key: "Enter", keyCode: 13, bubbles: true } ) );

await sleep(slow * 1);
web_inputbox = document.querySelectorAll(queryStr)[0];
web_inputbox.dispatchEvent ( new KeyboardEvent( "keyup", { key: "Enter", keyCode: 13, bubbles: true } ) );
}
}
}

setTimeout(start_go, before_start);
setTimeout(start_go, before_start);
}
Loading

0 comments on commit b051123

Please sign in to comment.