Skip to content
This repository has been archived by the owner on May 22, 2022. It is now read-only.

Commit

Permalink
Return speed for computation (Resolve #13)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfkz committed Jul 26, 2016
1 parent 5dd296b commit 6f8b72c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "__MSG_appName__",
"version": "0.5.2",
"version": "0.5.3",
"description": "__MSG_appDescription__",
"homepage_url": "http://re-coders.com/chessbot",
"default_locale": "en",
Expand Down
19 changes: 15 additions & 4 deletions scripts/chess_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ var Bot = function ($) {
if (i === movesMaded && movesArray[i].innerText !== '' && movesArray[i].innerText.indexOf('0') === -1) {
movesMaded++;
// b_console.log("Move: " + move);
return movesArray[i].innerText;
return movesArray[i].innerText.replace('O-O+', 'O-O'); // Sometimes it was happened
}
}
}
Expand Down Expand Up @@ -249,7 +249,8 @@ var PageManager = function($, window, cookieManager){
});

var previousMovesCount = 0;
function movesObserver () {
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
var observer = new MutationObserver(function(mutations, observer) {
// fired when a mutation occurs
var currentMovesCount = $(targets).filter(function () {
return !!this.innerText;
Expand All @@ -266,9 +267,19 @@ var PageManager = function($, window, cookieManager){
} else {
$('#robot_message').text('Game not available.');
}
}
});

setInterval(movesObserver, 1000);
var observeReadyInterval = setInterval(function(){
var observeTarget = isBetaDesign ? $('#LiveChessTopSideBarTabset .tab-content') : $('#chess_boards');
if (observeTarget.length > 0) {
observer.observe(observeTarget[0], {
subtree: true,
attributes: false,
childList: true
});
clearInterval(observeReadyInterval);
}
}, 5000);
// And go!
// enableSuggestion = false; // Fix trouble with cookie removing after refresh. // cookieManager.get(liveChessCookie) == '0';
// toggleSuggestionLive($('#robot_link')[0]);
Expand Down

0 comments on commit 6f8b72c

Please sign in to comment.