Skip to content

Commit

Permalink
Merge pull request #1 from litetex/develop
Browse files Browse the repository at this point in the history
Release 1.0.0
  • Loading branch information
litetex authored Sep 28, 2020
2 parents 126d697 + a6a1fae commit 7abbfcd
Show file tree
Hide file tree
Showing 20 changed files with 6,862 additions and 2 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Develop CI

on:
workflow_dispatch:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: 12.x

- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm install
working-directory: src

- run: npm run web-ext lint
working-directory: src
39 changes: 39 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Master CI

on:
workflow_dispatch:
push:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: 12.x

- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm install
working-directory: src

- run: npm run web-ext lint
working-directory: src

- run: npm run web-ext build
working-directory: src

- uses: actions/upload-artifact@v2
with:
name: built-artifacts
path: src/web-ext-artifacts/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web-ext-artifacts/
node_modules/
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
# predefined-cookie-loader
Loads, overrides and sets predefined cookies into your browser
[![build](https://img.shields.io/github/workflow/status/litetex/predefined-cookie-loader/Master%20CI?label=build)](https://github.com/litetex/predefined-cookie-loader/actions?query=workflow%3A%22Master+CI%22)
[![build develop](https://img.shields.io/github/workflow/status/litetex/predefined-cookie-loader/Develop%20CI?label=build%20develop)](https://github.com/litetex/predefined-cookie-loader/actions?query=workflow%3A%22Develop+CI%22)
# predefined-cookie-loader <img src="src/icons/icon96.png" width=56></img>

Loads, overrides and sets predefined 🍪 cookies into the browser

## Install
Install as [Firefox-Addon]()

## Use cases
### Private browsing
Your browser automatically deletes everything after you closed it? <br/>
<img src="assets/DeleteBrowsingDataOnClose.png" height=40></img>

And when you start it again everything is full of "We use cookies"-popups?<br/>
<img src="assets/CookiePopupExample.png" height=264></img>

Now you can preload the corresponding cookies:
```JSON
{
"<wellknownSearchEngine>.com": [
{
"name": "CONSENT",
"value": "YES+undefined.undefined+V14+undefined",
"secure": true
}
],
"<wellknownVideoPlatform>.com": [
{
"name": "CONSENT",
"value": "YES+undefined.undefined+V14+undefined",
"secure": true
}
]
}
```
Binary file added assets/CookiePopupExample.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/DeleteBrowsingDataOnClose.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"extensionName" : {
"message": "Predefined Cookie Loader",
"description": "Name of the extension"
},
"extensionNameShort" : {
"message": "PreCookieLoader",
"description": "Short name of the extension"
},
"extensionDescription" : {
"message": "Loads, overrides and sets predefined cookies",
"description": "Description of the extension"
},
"browserAction_settings" : {
"message": "Settings",
"description": "Opens the settings page"
},
"settings" : {
"message": "Settings",
"description": "settings"
},
"save" : {
"message": "Save",
"description": "save"
},
"cookies_for_preload": {
"message": "Cookies for preload",
"description": "Cookies for preload"
}
}
38 changes: 38 additions & 0 deletions src/background/scripts/cookieloader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"use strict";

function loadDefaultCookies() {
chrome.storage.local.get({
preLoadCookies: new Map()
}, function (data) {

try {
if (!data.preLoadCookies || !(data.preLoadCookies instanceof Map)) {
return;
}

data.preLoadCookies.forEach(function (value, key, map) {
let origin = "https://" + key;

console.log("Processing: '" + origin + "'");

value.forEach(cookie => {

let cookieToSet = Object.assign({ url: origin }, cookie);
if (!cookieToSet.domain) {
cookieToSet.domain = "." + key;
}

console.log(cookieToSet);

chrome.cookies.set(cookieToSet);
});
});

} catch (e) {
console.error(e);
}
});
}

chrome.runtime.onStartup.addListener(loadDefaultCookies);
chrome.runtime.onMessage.addListener(loadDefaultCookies);
4 changes: 4 additions & 0 deletions src/browserAction/browserAction.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
padding: 0.5em;
margin: 0;
}
13 changes: 13 additions & 0 deletions src/browserAction/browserAction.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>

<html>
<head>
<link href="browserAction.css" rel="stylesheet" type="text/css">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div id="actions"></div>
<script src="browserAction.js"></script>
</body>
</html>
33 changes: 33 additions & 0 deletions src/browserAction/browserAction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"use strict";

document.title = chrome.i18n.getMessage("extensionName") + " Menu";

function buildActions() {
const actions = document.getElementById('actions');
[
{
label: "settings",
action: function () {
if (chrome.runtime && chrome.runtime.openOptionsPage) {
chrome.runtime.openOptionsPage();
}
else {
window.open(chrome.extension.getURL("options/options.html"), "_blank");
}
}
}
].forEach(function (action) {
const btnAction = document.createElement("button");
btnAction.className = "action";

btnAction.appendChild(
document.createTextNode(
browser.i18n.getMessage("browserAction_" + action.label) || action.label
)
);
btnAction.addEventListener("click", action.action);
actions.appendChild(btnAction);
});
}

buildActions();
Binary file added src/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.
Binary file added src/icons/icon96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "__MSG_extensionName__",
"description": "__MSG_extensionDescription__",
"version": "1.0.0",
"homepage_url": "https://github.com/litetex/predefined-cookie-loader",
"author": "litetex",
"icons": {
"48": "icons/icon48.png",
"96": "icons/icon96.png"
},
"browser_action": {
"browser_style": true,
"default_title": "__MSG_extensionNameShort__",
"default_popup": "browserAction/browserAction.html"
},
"options_ui": {
"open_in_tab": true,
"page": "options/options.html"
},
"permissions": [
"http://*/*",
"https://*/*",
"cookies",
"storage"
],
"background": {
"scripts": [
"background/scripts/cookieloader.js"
]
},
"default_locale": "en",
"manifest_version": 2
}
38 changes: 38 additions & 0 deletions src/options/options.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
html, body {
margin: 0;
min-width: 100%;
height: 100%;
}

h2 {
margin: 0;
margin-top: 0.5em;
margin-bottom: 0.25em;
}

h4 {
margin: 0;
margin-top: 0.3em;
margin-bottom: 0.15em;
}

#options {
padding: 1em;
align-items: flex-start;
}

#cookiesForPreload {
align-self: stretch;
}

#save {
font-size: large;
}

#save-block {
align-items: baseline;
}

.save-failed {
color: darkred;
}
24 changes: 24 additions & 0 deletions src/options/options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<html>
<head>
<link href="../styles/shared.css" rel="stylesheet" type="text/css">
<link href="options.css" rel="stylesheet" type="text/css">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body class="flex-container-v">
<div id="options" class="flex-container-v flex-child-autogrow">

<h2 id="title"></h2>

<h4 id="cookiesForPreloadHeader"></h4>
<textarea id="cookiesForPreload" class="flex-child-autogrow" spellcheck="false"></textarea>

<div id="save-block" class="flex-container flex-child-contentsize">
<input type="button" id="save" class="flex-child-contentsize"/>
<span id="save-result" ></span>
</div>
</div>

<script src="options.js"></script>
</body>
</html>
Loading

0 comments on commit 7abbfcd

Please sign in to comment.