Skip to content

Commit

Permalink
✨ Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Schinkentanz committed Feb 26, 2019
0 parents commit 8a63c73
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]

# Change these settings to your own preference
indent_style = space
indent_size = 2

# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
1 change: 1 addition & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Binary file added icons/icon128.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 icons/icon16.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 icons/icon19.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 icons/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "amazon smile switcher",
"version": "1.0.0",
"manifest_version": 2,
"description": "Switch from amazon.de to smile.amazon.de",
"homepage_url": "https://www.amazon.de/",
"icons": {
"16": "icons/icon16.png",
"19": "icons/icon19.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
},
"default_locale": "en",
"background": {
"scripts": [
"src/bg/background.js"
],
"persistent": true
},
"permissions": [
"notifications",
"tabs",
"https://www.amazon.de/*"
],
"content_scripts": [
{
"matches": [
"https://www.amazon.de/*"
],
"js": [
"src/inject/inject.js"
]
}
]
}
12 changes: 12 additions & 0 deletions src/bg/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
chrome.extension.onMessage.addListener(({ href }, sender, sendResponse) => {
const switchToSmile = !/smile\.amazon\.de/.test(href);
if (switchToSmile) {
chrome.notifications.create('switch-to-smile-' + Date.now(), {
type: 'basic',
iconUrl: 'icons/icon128.png',
title: 'amazon.de',
message: 'Switched from amazon to smile.amazon'
}, (notificationId) => {});
}
sendResponse({ switchToSmile });
});
7 changes: 7 additions & 0 deletions src/inject/inject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { href } = window.location;

chrome.extension.sendMessage({ href }, ({ switchToSmile }) => {
if (switchToSmile) {
window.location.href = href.replace('www.amazon.de', 'smile.amazon.de');
}
});

0 comments on commit 8a63c73

Please sign in to comment.