Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8681095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:24:58+00:00 2026-06-12T21:24:58+00:00

I have been trying to write my first user script for Google Chrome. It

  • 0

I have been trying to write my first user script for Google Chrome. It checks the router page and reconnect until it gets a valid IP address.

I saved the script as IPchecker.user.js and installed it in google chrome via extensions page. But when I refresh the page, the javascript console throws an error:

Uncaught ReferenceError: wan_connect is not defined 

In this case, wan_connect is a function which was defined on the orginal page:

<html>
<head>
<script type="text/javascript">
    function serv(service, sleep)
    {
     form.submitHidden('service.cgi', { _service: service, _redirect: 'status-overview.asp', _sleep: sleep });
    }
    function wan_connect(wanid)
    {
     if (wanid == "1") {
     serv('wan1link-restart', 5);
     }
     if (wanid == "2") {
     serv('wan2link-restart', 5);
     }
    }

    //All other stuff deleted...

</script>
</head>
<body> Also deleted...</body>
</html>

Here is my script. Looks like it does not recognize the function from the original page. Is there a way to call it?

// ==UserScript==  
// @name         WAN checker
// @version      0.0.1
// @description  Check tomato IP addresses and reconnect as needed
// @match        *://192.168.1.1/status-overview.asp
// ==/UserScript== 

(function reconnect() {
    wan1ip = document.getElementById('wanip').getElementsByClassName('content')[0].innerText.split('.').slice(0,2).join('.');

    if (wan1ip != "333.3333") {
    wan_connect("1");
    setTimeout("reconnect()",2000);
    }
    wan2ip = document.getElementById('wan2ip').getElementsByClassName('content')[0].innerText.split('.').slice(0,2).join('.');
if (wan2ip != "333.333") {
    wan_connect("2");
    setTimeout("reconnect()",2000);
    }
})();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:25:00+00:00Added an answer on June 12, 2026 at 9:25 pm

    Yes, you can call that code in a few ways:

    1. Paste the appropriate source code into your script.

      or

    2. Call the original page in an iframe and call the function from there. Same-domain iframes are easier, but this can be done cross-domain as well.

      or

    3. Use GM_xmlhttpRequest() to grab the original page’s source code. Extract the appropriate script nodes from the source and inject that code into the current target page.

    All of these approaches have been covered, to some degree in previous userscripts and greasemonkey questions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to write my first user script for Google Chrome. It
I have been trying to write my own diff3 wrap script for SVN and
i have been trying to write a program in python to read two text
I have been trying to write some code in Scala to read a file
I have been trying to write a bare-bones ping scanner using Perl for internal
I have been trying to write an image on a layer using Quartz but
I have been trying to write a regex that will remove whitespace following a
I have been trying to write a custom .screenrc file TEST as follows startup_message
I have been trying to write a shortest path algorithm, dijkstras algorithm, finding the
I have a Bug at my simple REGEX. I have been trying to write

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.