-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Project C.A.T.S. #82
Merged
Merged
Project C.A.T.S. #82
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7be9a54
Initial work on Project CATS feature
tomasko126 d2c1e4d
Merge branch 'master' into project-cats
tomasko126 764d888
Resolve merge conflict
tomasko126 fff2d26
Improve the detection of a CATS user, minor enhancements
tomasko126 d3352c6
Remove localstorage key after running a content-script
tomasko126 0d2bb57
Add channels to the Options page by default, but leave them disabled …
tomasko126 e48b36f
Merge branch 'master' into project-cats
tomasko126 fd6edbe
Removed logs and other changes requested by Kieran
tomasko126 e09a155
Merge branch 'master' into project-cats
tomasko126 6cf8951
Fix Codacy issues
tomasko126 20bb3e4
Adjust switch block
tomasko126 c203339
Remove break;
tomasko126 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Run "CATS" detection code just on the dedicated page | ||
// cez execute script | ||
(function() { | ||
var key = "project-cats"; | ||
var shouldEnableCats = localStorage.getItem(key); | ||
|
||
if (shouldEnableCats) { | ||
chrome.runtime.sendMessage({ command: "enableprojectcats" }); | ||
} else { | ||
chrome.runtime.sendMessage({ command: "disableprojectcats" }); | ||
} | ||
|
||
// Remove the key from a local storage | ||
localStorage.removeItem(key); | ||
})(); |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
var CATS = { | ||
init: function(callback) { | ||
var self = this; | ||
|
||
// First-time running code after installation, set "CATS" to disabled by default | ||
// Opening up installed page, which will determine, | ||
// whether CATS should be enabled or not | ||
if (self.isEnabled() === undefined && sessionstorage_get("installed")) { | ||
sessionstorage_set("installed"); // present with a new user | ||
|
||
var installedURL = "https://catblock.tk/installed.html"; | ||
chrome.tabs.create({ url: installedURL }, function(data) { | ||
var tabId = data.id; | ||
var fileToInject = "js/cats-cs.js"; | ||
|
||
// Wait for a message from a content script, | ||
// which tells us to enable "CATS" | ||
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { | ||
if (request.command !== "enableprojectcats" && | ||
request.command !== "disableprojectcats") { | ||
return; | ||
} | ||
if (request.command === "enableprojectcats") { | ||
self.enable(); | ||
callback(); | ||
} else { | ||
self.disable(); | ||
callback(); | ||
} | ||
}); | ||
|
||
// Inject cats-cs content script, which determines, | ||
// whether Project CATS should be allowed or not | ||
chrome.tabs.executeScript(tabId, { file: fileToInject }); | ||
}); | ||
// When "CATS" is enabled, | ||
// we don't need to have our listener running | ||
} else if (self.isEnabled()) { | ||
return callback(); | ||
} else if (self.isEnabled() === false) { | ||
return callback(); | ||
} | ||
}, | ||
enable: function() { | ||
storage_set("project_cats", true); | ||
}, | ||
disable: function() { | ||
storage_set("project_cats", false); | ||
}, | ||
isEnabled: function() { | ||
//return true; | ||
return storage_get("project_cats"); | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not part of another PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kpeckett This was changed as part of a merge commit from
master
toproject-cats
branch.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try rebasing next time: https://www.atlassian.com/git/tutorials/merging-vs-rebasing/ avoids extra commits appearing.