-
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
0 parents
commit c82a451
Showing
6 changed files
with
79 additions
and
0 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,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); |
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,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(); | ||
}()); |
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,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"] | ||
} |