-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
url change popover created feature implemented
- Loading branch information
Showing
4 changed files
with
61 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,14 @@ | ||
chrome.runtime.onMessage.addListener( | ||
function(request, sender, sendResponse) { | ||
|
||
if(request === 'showPageAction'){ | ||
chrome.pageAction.show(sender.tab.id); | ||
} | ||
else { | ||
var http = new XMLHttpRequest(); | ||
|
||
http.open('GET', request.url, true); | ||
http.send(); | ||
|
||
http.onload = function () { | ||
sendResponse({prof: request.prof, result: http.responseText}); | ||
}; | ||
http.onerror = function () { | ||
sendResponse(); | ||
}; | ||
chrome.runtime.onMessage.addListener( | ||
function (request, sender, sendResponse) { | ||
if (request === 'showPageAction') { | ||
chrome.pageAction.show(sender.tab.id); | ||
} | ||
if (request === 'pageLoad') { | ||
alert('pageLoad'); | ||
} | ||
else { | ||
return true; // prevents the callback from being called too early on return | ||
} | ||
}); | ||
|
||
return true; // prevents the callback from being called too early on return | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,54 @@ | ||
/** | ||
* Created by Prayansh on 2016-12-21. | ||
*/ | ||
var targetAbility, | ||
abilities = []; | ||
|
||
targetAbility = $x("//ul[@class='AbilityList']/li"); | ||
targetAbility.forEach(function (element, index) { | ||
var abilityName = element.innerText; | ||
var abilityCode = abilityName.toLowerCase().replace(' ', '-'); | ||
var ability = { | ||
name: abilityName, | ||
code: abilityCode, | ||
index: index, | ||
div: element | ||
}; | ||
//give element an id for future | ||
element.id = abilityName.charAt(0) + index; | ||
|
||
// Setup loading animation for each popover | ||
$('#' + abilityName.charAt(0) + index).each(function () { | ||
var $elem = $(this); | ||
$elem.popover(popoverOptionsAbility($elem, ability)); | ||
|
||
function smogonHelper() { | ||
// console.log('Creating popups'); | ||
var targetAbility, | ||
abilities = []; | ||
|
||
targetAbility = $x("//ul[@class='AbilityList']/li"); | ||
targetAbility.forEach(function (element, index) { | ||
var abilityName = element.innerText; | ||
var abilityCode = abilityName.toLowerCase().replace(' ', '-'); | ||
var ability = { | ||
name: abilityName, | ||
code: abilityCode, | ||
index: index, | ||
div: element | ||
}; | ||
//give element an id for future | ||
element.id = abilityName.charAt(0) + index; | ||
|
||
// Setup loading animation for each popover | ||
$('#' + abilityName.charAt(0) + index).each(function () { | ||
var $elem = $(this); | ||
$elem.popover(popoverOptionsAbility($elem, ability)); | ||
}); | ||
|
||
abilities.push(ability); | ||
}); | ||
|
||
abilities.push(ability); | ||
for (var i = 0; i < abilities.length; i++) { | ||
bindPopupsToAbility(abilities[i]); | ||
} | ||
} | ||
|
||
var tBody = $x("//main[@data-reactid='.0.1']"); | ||
var tHead = $x("//h1[@data-reactid='.0.1.1.1']"); | ||
|
||
var observer = new MutationObserver(function (mutations) { | ||
mutations.forEach(function (mutation) { | ||
smogonHelper(); | ||
// console.log('something changed'); | ||
}); | ||
}); | ||
|
||
for (var i = 0; i < abilities.length; i++) { | ||
bindPopupsToAbility(abilities[i]); | ||
} | ||
// configuration of the observer: | ||
var config = {attributes: true, childList: true, characterData: true}; | ||
|
||
// pass in the target node, as well as the observer options | ||
observer.observe(tBody[0], config); | ||
observer.observe(tHead[0], config); | ||
|
||
smogonHelper(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters