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 770845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:33:49+00:00 2026-05-14T18:33:49+00:00

I’ve written a userscript for Gmail : Pimp.my.Gmail & i’d like it to be

  • 0

I’ve written a userscript for Gmail : Pimp.my.Gmail & i’d like it to be compatible with Google Chrome too.
Now i have tried a couple of things, to the best of my Javascript knowledge (which is very weak) & have been successful up-to a certain extent, though im not sure if it’s the right way.

Here’s what i tried, to make it work in Chrome:
The very first thing i found is that contentWindow.document doesn’t work in chrome, so i tried contentDocument, which works.
BUT i noticed one thing, checking the console messages in Firefox and Chrome, i saw that the script gets executed multiple times in Firefox whereas in Chrome it just executes once!
So i had to abandon the window.addEventListener('load', init, false); line and replace it with window.setTimeout(init, 5000); and i’m not sure if this is a good idea.

The other thing i tried is keeping the window.addEventListener('load', init, false); line and using window.setTimeout(init, 1000); inside init() in case the canvasframe is not found.

So please do lemme know what would be the best way to make this script cross-browser compatible.
Oh and im all ears for making this script better/efficient code wise (which im sure is possible)

edit: no help…? :'(

edit 28-Apr:
i re-wrote the code a little and now it looks something like this.:

if(document.location != top.location) return;

(function() {
var interval = window.setInterval(waitforiframe, 3000);
var canvas;
function waitforiframe() {
    console.log("Finding canvas frame");
    canvas = document.getElementById("canvas_frame");
    if (canvas && canvas.contentDocument) {
        console.log("Found canvas frame");
        pimpmygmail();
    }
}
function pimpmygmail() {
    gmail = canvas.contentDocument;
    if(!gmail) return;
    window.clearInterval(interval);
    console.log("Lets PIMP.MY.GMAIL!!!");
    ......rest of the code......
})();

This works perfectly fine in Firefox, but in Chrome, it gives me a top is undefined error.
Another thing i noticed is that if i remove the first line if(document.location != top.location) return; , the waitforiframe() method keeps getting called over and over again. (ie i see the "Finding canvas frame" error in the console)

can someone tell me what does the first line do? i mean what does it achieve & why does the waitforiframe() method run forever if i remove that line??

  • 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-05-14T18:33:50+00:00Added an answer on May 14, 2026 at 6:33 pm

    A BIG THANK YOU TO ALL WHO HELPED! -_- meh

    btw, this was all i needed at the beginning of the script:

    try { if(top.location.href != window.location.href) { return; } }
    catch(e) { return; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 400k
  • Answers 400k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can define a Layout that hold both TextView and… May 15, 2026 at 4:21 am
  • Editorial Team
    Editorial Team added an answer Short answer: IConnectableObservable represents a pending hot observable that can… May 15, 2026 at 4:21 am
  • Editorial Team
    Editorial Team added an answer >>> ts = time.mktime(time.strptime('20040412234551', '%Y%m%d%H%M%S')) >>> ts 1081809951.0 >>> datetime.datetime.fromtimestamp(ts)… May 15, 2026 at 4:21 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.