Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
adamboerema committed Dec 5, 2015
0 parents commit c82a451
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
Binary file added assets/icon_128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var s = document.createElement('script');
// TODO: add "script.js" to web_accessible_resources in manifest.json
s.src = chrome.extension.getURL('amazon_seller_checkbox.js');
s.onload = function() {
this.parentNode.removeChild(this);
};
(document.head || document.documentElement).appendChild(s);
50 changes: 50 additions & 0 deletions content_script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
(function(){
var AmazonSellerCheckbox = function(){

var complete = false;
var checkboxSelectors = [
'#displayOnDetailPage',
];

function checkboxPrompt(e){
if(!e.target.checked){
return false;
}
var confirmClick = confirm("Are you sure you want this promotion posted on your product page?");
if(confirmClick){
e.target.setAttribute('checked', true);
} else {
e.target.click();
e.target.setAttribute('checked', false);
}
}

function uncheckTargetedCheckboxes(){
checkboxSelectors.forEach(function(selector){
var checkboxes = document.querySelectorAll(selector);
if(checkboxes.length > 0){
for(var i=0; i<checkboxes.length; i++){
var checkbox = checkboxes[i];
if(checkbox.checked){
checkbox.setAttribute('checked', false);
checkbox.click();
checkbox.addEventListener("click", checkboxPrompt, true);
}
}
}
});
complete = true;
}

var intervalCheckboxes = setTimeout(function(){
if(!complete){
uncheckTargetedCheckboxes();
} else {
clearInterval(intervalCheckboxes);
}
}, 500);
};

//init
AmazonSellerCheckbox();
}());
21 changes: 21 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"manifest_version": 2,
"name": "Amazon Seller Checkbox",
"description": "Help protect your Amazon product promotion codes from being published on your product pages.",
"version": "1.0.0",
"permissions": [
"*://*/*"
],
"content_scripts": [{
"matches": ["*://*/*"],
"js": ["content_script.js"]
}],
"background": {
"scripts": ["background.js"]
},
"icons": {
"16" : "assets/icon_16.png",
"128" : "assets/icon_128.png"
},
"web_accessible_resources": ["img/logo.png"]
}

0 comments on commit c82a451

Please sign in to comment.