~jochen/Cuckie

5198fd09bb324793607b8874a8e269cd2201e3b6 — Jochen 10 months ago
initial commit
5 files changed, 69 insertions(+), 0 deletions(-)

A README.md
A background.js
A cuckie.js
A icon96.png
A manifest.json
A  => README.md +28 -0
@@ 1,28 @@
# Cuckie: User defined cookies
### Cuckie is a browser extension to create notifications based on personal browsing behaviors, by storing them in cookies.

![Cuckie](https://jochen.link/experiments/img/cuckie/extension_interface_2.jpg)

Visit [**https://jochen.link/experiments/cuckie.html**](https://jochen.link/experiments/cuckie.html) for more information.


## Setup
- Download and unzip Cuckie folder
- Go to “extensions” in your browser options
- Enable “developer mode”
- Click “load unpacked”
- Navigate to Cuckie folder and select it
- If you don't see the extension in your browser bar please pin it
[**https://www.howtogeek.com/683099/how-to-pin-and-unpin-extensions-from-the-chrome-toolbar/**](How to pin a browser extension)


## Usage
- Visit any website
- Click the extension icon
- Type in a note for the website you are currently on
- Press "bake" to store the note in a user-generated cookie, or "eat" to close the Cuckie window
- Reload the website
- The Cuckie window will appear and display the message you saved
- Click "eat" to delete the cookie, or "keep" to keep it.
- You can open and close the Cuckie window anytime by clicking the extension icon
- Pressing escape closes the Cuckie window as well
\ No newline at end of file

A  => background.js +5 -0
@@ 1,5 @@
chrome.browserAction.onClicked.addListener(function(){
	chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
  		chrome.tabs.sendMessage(tabs[0].id, {create: "cuckie"});
	});
});
\ No newline at end of file

A  => cuckie.js +1 -0
@@ 1,1 @@
var note,cuckie_css='#cuckie_win{ position:fixed !important; margin: 0 !important; padding: 0 !important; width: 300px !important; height: 360px !important; top: 50% !important; left: 50% !important; transform: translate(-50%, -50%) !important; z-index: 99999 !important; border: solid 2px black !important; box-shadow: 10px 10px #000 !important; background: #fff !important;} #cuckie_type{ position:fixed !important; margin: 0 !important; width: 255px !important; height: 264px !important; top: 20px !important; left: 20px !important; z-index: 999999 !important; font-family: "Courier New" !important; font-size: 16px !important; line-height: 1.5 !important; outline: none !important; border: none !important; resize: none !important; box-shadow: 0 0 0 3px #fff !important; background-color: #fff; overflow: hidden !important;} #cuckie_bake{ position:fixed !important; width: 154px !important; height: 50px !important; left: -2px !important; bottom: -2px !important; z-index: 999999 !important; background: #fff !important; border: solid 2px #000 !important; outline: none !important; color: #000 !important; font-family: "arial black" !important; font-size: 20px !important; text-align: center !important;} #cuckie_eat{ position:fixed !important; width: 154px !important; height: 50px !important; bottom: -2px !important; right: -2px !important; z-index: 999999 !important; background: #fff !important; border: solid 2px #000 !important; outline: none !important; color: #000 !important; font-family: "arial black" !important; font-size: 20px !important; text-align: center !important;} #cuckie_bake:hover{ background-color: #000 !important; color: #fff !important;} #cuckie_eat:hover{ background-color: #000 !important; color: #fff !important;}',style=document.createElement("style");function setCuckie(t){var e=new Date;e.setTime(e.getTime()+2592e6),document.cookie="cuckie="+t+"; expires="+e.toGMTString()}function getCuckie(t){for(var e=t+"=",n=document.cookie.split(";"),i=0;i<n.length;i++){for(var o=n[i];" "==o.charAt(0);)o=o.substring(1);if(0==o.indexOf(e))return o.substring(e.length,o.length)}return""}function deleteCuckie(){note=getCuckie("cuckie"),document.cookie="cuckie= ; expires = Thu, 01 Jan 1970 00:00:00 GMT"}function interfaceCuckie(){note=getCuckie("cuckie"),style.styleSheet?style.styleSheet.cssText=cuckie_css:style.appendChild(document.createTextNode(cuckie_css)),document.getElementsByTagName("head")[0].appendChild(style);var t=document.createElement("div"),e=document.createElement("button"),n=document.createElement("button"),i=document.createElement("textarea");t.setAttribute("id","cuckie_win"),i.setAttribute("id","cuckie_type"),e.setAttribute("id","cuckie_bake"),n.setAttribute("id","cuckie_eat"),i.setAttribute("autofocus",!0),i.setAttribute("spellcheck",!1),i.setAttribute("placeholder","note for this site"),i.setAttribute("rows","10"),i.setAttribute("cols","24"),i.setAttribute("wrap","hard"),i.setAttribute("data-lmit-rows","true"),t.appendChild(i),t.appendChild(e),t.appendChild(n),document.body.appendChild(t);var o=document.getElementById("cuckie_win"),r=document.getElementById("cuckie_type"),c=document.getElementById("cuckie_bake"),a=document.getElementById("cuckie_eat");c.innerHTML=""!=note?"keep":"bake",a.innerHTML="eat",i.setAttribute("onkeyup","(function(){if(document.getElementById('cuckie_bake').innerHTML=='keep'){console.log('change');document.getElementById('cuckie_bake').innerHTML='bake'}})();return false;"),c.onclick=function(){""!=(note=r.value)&&null!=note&&(setCuckie(note),o.style.display="none")},a.onclick=function(){deleteCuckie(),r.value="",o.style.display="none"},""!=note?(o.style.display="block",r.value=note):o.style.display="none",limit()}function limit(){var t=document.getElementById("cuckie_type"),e=t.getAttribute("cols");t.onkeyup=function(){for(var n=t.value.split("\n"),i=0;i<n.length;i++)if(!(n[i].length<=e)){for(var o=0,r=e;o++<=e;)" "===n[i].charAt(o)&&(r=o);n[i+1]=n[i].substring(r+1)+(n[i+1]||""),n[i]=n[i].substring(0,r)}n.length>10&&(t.style.color="red",setTimeout(function(){t.style.color=""},500)),t.value=n.slice(0,10).join("\n")}}interfaceCuckie(),chrome.runtime.onMessage.addListener(function(t,e,n){var i=document.getElementById("cuckie_win"),o=document.getElementById("cuckie_type"),r=document.getElementById("cuckie_bake");"cuckie"==t.create&&(note=getCuckie("cuckie"),o.value=note,""!==note&&(r.innerHTML="keep"),"none"==i.style.display?(i.style.display="block",o.focus()):i.style.display="none")}),document.onkeydown=function(t){27==(t=t||window.event).keyCode&&(document.getElementById("cuckie_win").style.display="none")};
\ No newline at end of file

A  => icon96.png +0 -0
A  => manifest.json +35 -0
@@ 1,35 @@
{
  "manifest_version": 2,
  "version": "0.1",
  "name": "chrome cookie",
  "description": "Capture pop-up notes for any website, by storing them in user-generated cookies. ",
  "author": "Jochen Maria Weber / asWeMay",
  "icons": {"96": "icon96.png"},
  "browser_action": {
    "default_icon": "icon96.png"
  },
  "permissions": [
    "tabs",
    "activeTab",
    "http://*/*",
    "https://*/*"
  ],
  "background":{
        "scripts":[ 
            "background.js"
            ],
        "persistent": false
    },
  "content_scripts": [
    {
      "matches": [
        "<all_urls>"
      ],
      "js": ["cuckie.js"]
    }
  ]
}



  
\ No newline at end of file