https://www.j2h.tw/test2/test.php
找到關鍵字 ,highlight關鍵字
$(document).ready(function() {
$("body").html(function(){
return $(this).html().replace(/装修蟑螂|消费者|師傅|統包/g, '$&');
});
});
這段程式碼可以加入如果沒找到關鍵字 網頁向下滑在執行,直到找到
$(document).ready(function() {
var intervalId = setInterval(function() {
var found = $("body").html().match(/装修蟑螂|消费者|師傅|統包/);
if(found){
clearInterval(intervalId);
$("body").html(function(){
return $(this).html().replace(/装修蟑螂|消费者|師傅|統包/g, '$&');
});
}else{
window.scrollBy(0, 100);
}
}, 1000);
});
程式碼加入 開始鍵和停止鍵
$(document).ready(function() {
var intervalId;
$("#startBtn").click(function(){
intervalId = setInterval(function() {
var found = $("body").html().match(/協議條款|法院查詢|滿天喊價/);
if(found){
clearInterval(intervalId);
$("body").html(function(){
return $(this).html().replace(/協議條款|法院查詢|滿天喊價/g, '$&');
});
}else{
window.scrollBy(0, 100);
}
}, 1000);
});
$("#stopBtn").click(function(){
clearInterval(intervalId);
});
});
$(document).ready(function() {
$('body').append('');
$('body').append('');
$('#startBtn').css({
'position': 'fixed',
'top': '10px',
'left': '10px'
});
$('#stopBtn').css({
'position': 'fixed',
'top': '40px',
'left': '10px'
});
var intervalId;
$("#startBtn").click(function(){
intervalId = setInterval(function() {
var keyword = /協議條款|法院查詢|滿天喊價/g;
var found = $("body").html().match(keyword);
if(found){
clearInterval(intervalId);
$("body").html(function(){
return $(this).html().replace(keyword, '$&');
});
}else{
window.scrollBy(0, 100);
}
}, 1000);
});
$("#stopBtn").click(function(){
clearInterval(intervalId);
});
});
|