How to make a extension/script/program that will refresh a browser until a certain phrase/keyword is found or is not found? -
Is there a program / extension that I can use with browsers that will refresh a webpage and a certain phrase or Search the text and then stop or can not be found when the phrase is closed.
For example, I have created a site in which a rand iMaser was used through the word "one," "two," and "three".
This program will refresh the page, unless the word "three" is found, if I set it to search for that word, and then stop it after it is found.
OR
This program will refresh the page until the word "three" is found, if I set it to search for that word, and then turn it off Not stopped after it is closed.
I know that we can use curls and grep to do this, but the page has not been loaded on webbrowser. This is not what I want. See if there is a solution that we can also load on the browser
If such a thing is not present, then how to write such a program, but any thoughts? Which tool to use it?
You can write an extension very easily to do this. Instead of refreshing the page every time I suggest, you choose the data as long as you do not get the desired results, then refresh the page when you find it. A short example of using jQuery is because I'm familiar with it:
Manifest.json popup html popup.js bgp.js If the tab needs to be refreshed every time (the content changes between the time when you were looking for it and refreshed the page) you should use it You should test for the desired value and send a message on the background page if the desired picture is not to refresh the page and start over again. Like this: bgp.js checkText.js
{"name": "Find text "," Version ":" 0.1 "," description ":" find text "," manifest_version ": 2," browser_action ": {" default_icon ":" on.png "," default_popup ":" popup.html "} , "Permissions": ["tab", "http: // * / *", "https: // * / *"], "background": {"script": ["bgp.js", "jquery- 1.8.3 .min.js "]," continuous ": true}}
& lt ;; DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Style & gt; Body {width: 300px; } & Lt; / Style & gt; & Lt; Script src = "jquery-1.8.3.min.js" & gt; & Lt; / Script & gt; & Lt; Script src = "popup.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div & gt; Desired search URL & lt; / Div & gt; & Lt; Input type = "text" id = "searchUrl" & gt; & Lt; Div & gt; Desired search text & lt; / Div & gt; & Lt; Input type = "text" id = "searchText" & gt; & Lt; Button ID = "Search Button" & gt; Search & lt; / Button & gt; & Lt; / Body & gt; & Lt; / Html & gt;
$ (function () {var tabId; chrome.tabs.query ({active: true , CurrentWindow: true}, function (tab) {$ ('# searchUrl'). Val (tab [0] .url); tabId = tab [0] .id;}); $ ('# searchButton'). Function () {chrome.extension.sendMessage ({url: $ ('# searchUrl'). Val (), text: $ ('# searchText'). Val (), tab: tabId});})}} ;
chrome.extension.onMessage.addListener (function (send message, sender, send dispatch) {checkUrlForText (Message.url, message.text, message.tab);}); The function is included in URL url, text (url, text, tab) {var; $ Ajax ({url: url, async: false, success: function (data) {in = $ (': in (' + text + '), data); while (this includes length == 0) {$. Ajax ({Url: url, async: false, success: function (dat) {contains = $ (': ((' + text + '), dat}}}})}}}}); Chrome.tabs.reload (tab); }
var contains; Chrome.extension.onMessage.addListener (function (message, sender, send display) {checkTabForText (message.text, message.tab); in = false;}); Function checkababyfo text (text, tab) {chrome.tabs.executeScript (tab, {file: "jquery-1.8.3.min.js"}); Chrome.tabs.executeScript (tab, {file: "checkText.js"}, function () {chrome.tabs.sendMessage (tab, {text: text}, function (response) {has = response; if (included! ) {Chrome.tabs.reload (tab, function () {checkTabForText (text, tab);})}}}};}); }
chrome.extension.onMessage.addListener (function (message, sender, send display) {var (=: Message.text + ')); If (included in length = gt; 0) sending response ({contains: true}); Send another dispatch ({include: wrong});});
Comments
Post a Comment