The picture above shows the problem. You can't directly search double quote inside the HTML viewer in Chrome. So what is the proper way to search it?
Related
I am trying to find a way to replace certain text on the webpage without the use of chrome extensions.
For example, I want the text 'dogs' to replace with 'doggos' each time the web page detects the word dogs. Is it possible to do this without the use of Chrome Extensions? How can I write such a script and can this run in the backgroun?
Thanks all!
Use Chrome Dev Tools
If you want to use chrome, but not a chrome extension, you want to use the console in the Chrome Dev Tools. Running a script for a website on the Chrome Console is a solution to your question, and is shown below, but it will disappear when you refresh the page.
Replacing String Literals in the Body
To replace all instances of dogs with doggos in the HTML body, you would walk the document tree as documented by this SO question.
Applied to your question, the result is below:
Further Reading
You may also want to check out javascript with Regular Expressions, which are more powerful than a simple string replace. If you want this running in the background, you should look at Mutation Observers to check whether the DOM has changed.
I am working in Chrome developer tools and looking for a way to show HTML entities by default.
The view I see is this:
Whereas, the view I need is this:
Does anybody know how I can enable the view I need?
I know there is a theme engine for Chrome but is there an existing feature that fits my needs?
Thanks guys ;)
I had this same question and discovered that with chrome, right-click > View Source code, shows the pure un-decoded(un-evaluated) html entities while the right-click > inspect option seems to evaluate them... may help someone:)
In Google Chrome the correct way to see the actual source of the document that is currently loaded is to click the Sources tab and choose the file from the tree on the left. If you have a unique string on the line that you're searching for, you can press Ctrl-Shift-F to search all files for that string.
RightClick -> View Source is incorrect because it reloads the document, which may cause unexpected behaviour.
Inspect Element is incorrect because it displays the current DOM, not the HTML source.
You can't: The DOM Inspector shows a view of the DOM, not the source code.
The HTML has already been parsed and the entities converted to characters in text nodes.
The Inspector shows an HTML-like view because it is easy to understand. It doesn't reflect the original source code.
Browsers have an explicit "View Source" feature if you want to see the source code.
In Google Chrome, if I create a prompt with an Emoji character, it looks fine there. But, if I put in an input field or in the page itself, all the characters look weird with a square and a cross.
Do you know if this is something I can fix easily?
Is it the charset used in the page (utf-8)?
Is it the font I'm using?
Thank you.
Prompt:
Textarea:
Chrome developer tools can search for elements inside HTML. Is there a way to replace all occurrences of HTML code which is matched by some custom expression (similar to standard text editors' Replace All function)?
UPDATE:
Snippets come very handy handling text replacement:
You can create a script to find/replace and run it in the console tab.
For a manual HTML change, you can right click on any element and pick Edit as HTML.
I wrote a chrome extension - english dictionary. You select word, the definition appears.
It works well, but I counter a problem. It seems there is no api of chrome pdf viewer supplied by google.
How can I get the word when i select a word in pdf using chrome pdf viewer?
I will be appreciate if you could help me.
You can get selected text using the context menu. In your background script, adding these lines will allow the user to right-click and do something with the selectionText.
chrome.contextMenus.create({id:"lookup",title:"Lookup %s",contexts:["selection"]});
chrome.contextMenus.onClicked.addListener(function(sel){
console.log(sel.selectionText);
});
Grabbing this text works fine with PDFs, whether part of the extension, or not.
However, you cannot inject a script into a page starting with "chrome-extension://". If this is how your extension works, that will not be (directly) possible. But getting the selected text, and doing something with it still very doable.
As an alternative to requiring script injection, see the notification api, which allows a small message to popup, which could contain the definition of the word.