Welcome guest, is this your first visit? Create Account now to join.
Results 1 to 2 of 2

This is a discussion on Check Page Text within the Plugins Development section, part of the Chrome Plugins category: Hello, i am new to this forum but not at programming. I want to create a Plugin which checks if ...


  1. #1
    e_ndo is offline Junior Member
    Join Date
    Mar 2012
    Posts
    1

    Default Check Page Text

    Hello,

    i am new to this forum but not at programming. I want to create a Plugin which checks if the current website contains a text, like "Hello World" and if yes the plugin saves the url in a variable in javascript. Is that possible?

    Thanks.

  2. #2
    PAEz's Avatar
    PAEz is offline Moderator
    Join Date
    Aug 2009
    Location
    Australia
    Posts
    656

    Default

    You could just use document.body.innerHTML and search in that (which will search all the html of the page (well the body of it anywayz)), or if you just want to search text on the page you could do something like....


    // This was just a quick look at changing text on a page
    // there could be more tags you should ignore and there could be a better way of doing this all together
    var ignoreTags = ["NOSCRIPT","SCRIPT","STYLE"];
    var nodeIterator = document.createNodeIterator( document, NodeFilter.SHOW_TEXT, function (node){
    var parentTag = node.parentNode.tagName.toUpperCase();
    if ( ignoreTags.indexOf(parentTag)==-1 ) {return true} else {return false}; },
    false);
    var node;
    while ( (node = nodeIterator.nextNode()) ) {
    if (textNode.data.search('google')) {
    //Found it, so do something....youd prolly store the result in localStorage
    alert('Found "google"'); }
    }
    Youd put this script in a content script with a matches field of <all_urls> and prolly store the result in localStorage and then react to it what ever way you have planned.

    PS...the official place for asking questions on making Chrome extensions is now StackOverflow....
    http://stackoverflow.com/questions/t...rome-extension
    ...I havent been here in ages , but youll always find help at StackOverflow
    Last edited by PAEz; 03-21-2012 at 04:46 PM.

Similar Threads

  1. (X) or Check Mark next to title in tab
    By vbdoug in forum Chrome Troubleshooting
    Replies: 2
    Last Post: 09-07-2012, 12:51 PM
  2. Edit text with your favorite text editor in Chrome!
    By Channing1 in forum Chrome Tips & Tricks
    Replies: 9
    Last Post: 08-02-2012, 04:21 AM
  3. Replies: 0
    Last Post: 08-08-2011, 07:35 AM
  4. Make black text & white page by 1 click
    By vietnam in forum Chrome Tips & Tricks
    Replies: 7
    Last Post: 10-29-2010, 10:50 PM
  5. To disable spell check in textarea
    By Rejish in forum Chrome Troubleshooting
    Replies: 2
    Last Post: 09-11-2009, 12:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •