-
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.
- Loading branch information
AP
authored and
AP
committed
Apr 16, 2020
1 parent
6a60e3b
commit 0a5eff9
Showing
6 changed files
with
5,832 additions
and
23 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,24 +1,46 @@ | ||
|
||
chrome.runtime.onInstalled.addListener(function() { | ||
chrome.tabs.executeScript({ | ||
file: 'contentScript.js' | ||
}); | ||
chrome.contextMenus.create({ | ||
"id": "ContextMenu", | ||
"title": "Context Menu", | ||
"contexts": ["selection"] | ||
}); | ||
}); | ||
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() { | ||
chrome.declarativeContent.onPageChanged.addRules([{ | ||
conditions: [new chrome.declarativeContent.PageStateMatcher({ | ||
pageUrl: {hostEquals: 'developer.chrome.com'}, | ||
}) | ||
], | ||
actions: [new chrome.declarativeContent.ShowPageAction()] | ||
}]); | ||
|
||
function commentsPopup() { | ||
chrome.tabs.executeScript({ | ||
code: 'console.log(document)' | ||
// code: 'comment();' | ||
// file: 'contentScript.js', | ||
// code: `let menu = document.createElement("div"); | ||
// menu.innerHTML = ('<div id="comment-menu"> | ||
// <input id="comment-field"></input> | ||
// <button>Add comment</button> | ||
// </div>'); | ||
// document.body.appendChild(menu); | ||
// console.log(document)` | ||
}); | ||
|
||
let comment = prompt('enter a comment'); | ||
} | ||
|
||
chrome.runtime.onInstalled.addListener(function() { | ||
chrome.contextMenus.create({ | ||
"id": "ContextMenu", | ||
"title": "Annotate", | ||
"contexts": ["all"], | ||
}); | ||
}); | ||
|
||
chrome.contextMenus.onClicked.addListener(function() { | ||
commentsPopup(); | ||
}); | ||
|
||
chrome.runtime.onMessage.addListener(function() { | ||
chrome.tabs.executeScript({ | ||
file: 'contentScript.js' | ||
}); | ||
}); | ||
|
||
// document.querySelector('#button').addEventListener('click', function() { | ||
// console.log(this); | ||
// }) | ||
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() { | ||
chrome.declarativeContent.onPageChanged.addRules([{ | ||
conditions: [new chrome.declarativeContent.PageStateMatcher({ | ||
pageUrl: {hostEquals: 'developer.chrome.com'}, | ||
}) | ||
], | ||
actions: [new chrome.declarativeContent.ShowPageAction()] | ||
}]); | ||
}); |
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,3 +1,12 @@ | ||
|
||
function comment() { | ||
let menu = document.createElement("div"); | ||
menu.innerHTML = (`<div id="comment-menu"> | ||
<input id="comment-field"></input> | ||
<button>Add comment</button> | ||
console.log(document) | ||
</div>`); | ||
document.body.appendChild(menu); | ||
} | ||
comment(); | ||
|
||
console.log(document) |
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
Oops, something went wrong.