Google Keep Colour Bar

Add custom pens and markers to Google Keep's drawing toolbar

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

You will need to install an extension such as Tampermonkey to install this script.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Google Keep Colour Bar
// @version      0.1
// @description  Add custom pens and markers to Google Keep's drawing toolbar
// @author       yallinthehall
// @match        https://keep.google.com/
// @grant        none
// @namespace https://greasyfork.org/users/312448
// ==/UserScript==

window.addEventListener('load', function() {
    'use strict';

const markerPlace = document.querySelector("#canvas-parent > div.above-ink-canvas > div > div > div.ink-toolbar-begin > div:nth-child(5)");
const resetBlackPen = document.querySelector("#canvas-parent > div.below-ink-canvas > div:nth-child(1) > div.ink-color-rows-container > div:nth-child(1) > button:nth-child(1)");
const resetBrownPen = document.querySelector("#canvas-parent > div.below-ink-canvas > div:nth-child(1) > div.ink-color-rows-container > div:nth-child(1) > button:nth-child(7)");

const highlighterPlace = document.querySelector("#canvas-parent > div.above-ink-canvas > div > div > div.ink-toolbar-begin > div:nth-child(6)")
const resetBlackMarker = document.querySelector("#canvas-parent > div.below-ink-canvas > div:nth-child(2) > div.ink-color-rows-container > div:nth-child(1) > button:nth-child(1)");
const resetBrownMarker = document.querySelector("#canvas-parent > div.below-ink-canvas > div:nth-child(2) > div.ink-color-rows-container > div:nth-child(1) > button:nth-child(7)");

Element.prototype.appendBefore = function(element) {
  element.parentNode.insertBefore(this, element);
}, false;

var allPens = [];
var allMarkers = [];
allPens.push("#000000"); //BLACK
allPens.push("#000F55"); //BLUE INK
allPens.push("#d500f9"); //PURPLE
allPens.push("#00c853"); //GREEN
allPens.push("#ff0000"); //RED

allMarkers.push("#000000"); //BLACK
allMarkers.push("#ffbc00"); //PURPLE
allMarkers.push("#00c853"); //GREEN
allMarkers.push("#ff0000"); //RED

var newPen;
for (const colour of allPens){
	newPen = document.createElement("button");
	newPen.setAttribute("class", "ink-color");
	newPen.setAttribute("tabindex", "0");
	newPen.setAttribute("style", "background:" + colour +";");
	newPen.addEventListener("click", function() {
		resetBlackPen.click();
		resetBrownPen.setAttribute("color-data", colour);
		resetBrownPen.click();
	});
	newPen.appendBefore(markerPlace);
}

for (const colour of allMarkers){
	newPen = document.createElement("button");
	newPen.setAttribute("class", "ink-color");
	newPen.setAttribute("tabindex", "0");
	newPen.setAttribute("style", "background:" + colour +";");
	newPen.addEventListener("click", function() {
		resetBlackMarker.click();
		resetBrownMarker.setAttribute("color-data", colour);
		resetBrownMarker.click();
	});
	newPen.appendBefore(highlighterPlace);
}
},false);