dhruvagarwal / geekometer

This chrome extension keeps a track of the problems solved by you on geeksforgeeks.org, and crosses them out.Hence, easing it out for you to concentrate on missed ones
Apache License 2.0
36 stars 16 forks source link

inline js -> listener based + several changes #3

Closed mebjas closed 9 years ago

mebjas commented 9 years ago

Tested - all olds things working To make things work made several changes on the way.

Problem 1: Since the funcs.js is injected, listeners could not be added till the script has loaded and functions, for ex initiate() is loaded. Also since the funcs.js is now loaded into page, the variables and functions doesn't comes to content scripts scope.

Solutions:

  1. created a class scriptInjection to load scripts into main HTML, just to ease in the process
  2. Now since the functions are not in scope all event listeners need to be attached from the main scope of gfg, so created another script meant for loading listeners - listeners.js

    problem 2: the initiate is not loaded into memory even at the point the listeners is attached, {probably due to async nature} so attached it under a wrapper - listeners.js line#16, so this would still point to window object.

Solution: passed the reference object to initate and changed its definition to act accordingly

dhruvagarwal commented 9 years ago

Thanks a ton dude :+1: This was very informative !

mebjas commented 9 years ago

:D to me too!