]> git.wh0rd.org - chrome-ext/waterfall-buildbot-clicker.git/commitdiff
initial code main
authorMike Frysinger <vapier@gentoo.org>
Sun, 28 Feb 2016 19:39:57 +0000 (14:39 -0500)
committerMike Frysinger <vapier@gentoo.org>
Sun, 28 Feb 2016 19:39:57 +0000 (14:39 -0500)
Makefile [new file with mode: 0644]
background.html [new file with mode: 0644]
background.js [new file with mode: 0644]
click_all.js [new file with mode: 0644]
icon-128x128.png [new file with mode: 0644]
icon-96x96.png [new file with mode: 0644]
icon.svg [new file with mode: 0644]
makedist.sh [new file with mode: 0755]
manifest.files [new file with mode: 0644]
manifest.json [new file with mode: 0644]
pngcrush.sh [new file with mode: 0755]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..f53d535
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,38 @@
+# http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/
+CLOSURE = closure-compiler --language_in ECMASCRIPT5 --js $1 --create_source_map $1.map --source_map_format=V3 --js_output_file $1.min
+YUICOMPRESSOR = yuicompressor
+HTMLMINIFIER = html-minifier \
+       --collapse-whitespace \
+       --remove-attribute-quotes \
+       --remove-redundant-attributes \
+       --remove-empty-attributes \
+       --remove-comments
+
+all:
+
+min: css-min html-min js-min
+
+%.js.min: %.js
+       $(call CLOSURE,$<)
+
+JS_FILES = $(shell grep '[.]js$$' manifest.files)
+js-min: $(JS_FILES:=.min)
+
+%.css.min: %.css
+       $(YUICOMPRESSOR) $< > $@
+
+CSS_FILES = $(shell grep '[.]css$$' manifest.files)
+css-min: $(CSS_FILES:=.min)
+
+%.html.min: %.html
+       $(HTMLMINIFIER) $< > $@
+
+HTML_FILES = $(shell grep '[.]html$$' manifest.files)
+html-min: $(HTML_FILES:=.min)
+
+check: html-min css-min js-min
+
+dist:
+       ./makedist.sh
+
+.PHONY: all clean check css-min dist html-min js-min
diff --git a/background.html b/background.html
new file mode 100644 (file)
index 0000000..1b4d9f5
--- /dev/null
@@ -0,0 +1,8 @@
+<html>
+<head>
+<script src='background.js'></script>
+</head>
+<body id='test''>
+  <canvas id='canvas' width='19' height='19'></canvas>
+</body>
+</html>
diff --git a/background.js b/background.js
new file mode 100644 (file)
index 0000000..6eaae37
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright 2014 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var storage = chrome.storage.local;
+
+// When visiting a waterfall page, show the icon.
+console.log('going...');
+chrome.webNavigation.onCommitted.addListener(function(e) {
+  setIcon(e.tabId);
+}, {url: [{hostEquals: 'uberchromegw.corp.google.com'},
+          {hostEquals: 'chromegw.corp.google.com'}]});
+
+function onClicked(tab) {
+  if (window.confirm('nuke them all?')) {
+    chrome.tabs.executeScript(tab.id, {
+      'file': 'click_all.js'
+    });
+  }
+}
+
+chrome.pageAction.onClicked.addListener(onClicked);
+
+function setIcon(tabId) {
+  //chrome.pageAction.setPopup({'tabId':tabId, 'popup':'popup.html'});
+  chrome.pageAction.setIcon({'tabId':tabId, 'path':'icon-96x96.png'});
+  chrome.pageAction.setTitle({'tabId':tabId, 'title':'Nuke It'});
+  chrome.pageAction.show(tabId);
+}
diff --git a/click_all.js b/click_all.js
new file mode 100644 (file)
index 0000000..e4c921d
--- /dev/null
@@ -0,0 +1,47 @@
+function $(s) { return document.querySelectorAll(s); }
+function $$(s) { return document.querySelector(s); }
+
+function pause(msec) {
+  var date = new Date();
+  while (new Date() - date < msec)
+    continue;
+}
+
+var max = 400;
+
+var forms = $('form[name=cancel]');
+var i, f, id, http, url, params, total;
+total = 0;
+for (i = 0; i < forms.length - 1 && i < max; ++i) {
+  ++total;
+
+  f = forms[i];
+  id = f.querySelector('input[name=id]');
+
+  http = new XMLHttpRequest();
+  http.onreadystatechange = function(state) {
+    if (this.readyState == 4) {
+      if (--total <= 0)
+        window.location.reload();
+      console.log('finished one', this.status);
+    }
+  };
+
+  url = document.URL + '/cancelbuild';
+  params = 'id=' + id.value;
+  http.open('POST', url, true);
+  console.log('hitting url', url, params);
+
+  http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
+  http.send(params);
+  pause(5);
+}
+console.log('spawned ' + total);
+if (total != forms.length) {
+       console.log('total available: ' + forms.length);
+}
+
+//i = 5 * forms.length;
+//console.log('waiting', i, 'msecs');
+//pause(i);
+//window.location.reload();
diff --git a/icon-128x128.png b/icon-128x128.png
new file mode 100644 (file)
index 0000000..0d3807b
Binary files /dev/null and b/icon-128x128.png differ
diff --git a/icon-96x96.png b/icon-96x96.png
new file mode 100644 (file)
index 0000000..71368e1
Binary files /dev/null and b/icon-96x96.png differ
diff --git a/icon.svg b/icon.svg
new file mode 100644 (file)
index 0000000..fab3ee6
--- /dev/null
+++ b/icon.svg
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="600" height="600" viewBox="-300 -300 600 600">
+<circle r="292.3"/>
+<g style="fill:#f1cd43" transform="scale(0.9783764)">
+       <circle r="50"/>
+       <path d="M75,0A75,75 0 0,0 37.5-64.951905L125-216.50635A250,250 0 0,1 250,0Z" id="bld"/>
+       <use xlink:href="#bld" transform="rotate(120)"/>
+       <use xlink:href="#bld" transform="rotate(240)"/>
+</g>
+</svg>
\ No newline at end of file
diff --git a/makedist.sh b/makedist.sh
new file mode 100755 (executable)
index 0000000..9ecf0bf
--- /dev/null
@@ -0,0 +1,70 @@
+#!/bin/bash -e
+# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+cd "${0%/*}"
+
+case $1 in
+-h|--help)
+  echo "Usage: $0 [rev]"
+  exit 0
+  ;;
+esac
+
+rev=${1:-0}
+if [[ $# -gt 1 || -n ${1//[0-9]} ]] ; then
+  cat <<-EOF
+Usage: makedist.sh <rev>
+
+The ver will be taken from manifest.json.
+
+The rev should be an integer.
+
+Example:
+ ./makedist.sh 1
+This will generate a manifest for version 3.0.1 (when version is '3.0'
+in the manifest.json file)
+EOF
+  exit 0
+fi
+
+json_value() {
+  local key=$1
+  sed -n -r \
+    -e '/^[[:space:]]*"'"${key}"'"/s|.*:[[:space:]]*"([^"]*)",?$|\1|p' \
+    manifest.json
+}
+
+PN=$(json_value name | sed 's:[[:space:]/]:_:g' | tr '[:upper:]' '[:lower:]')
+if [[ ${PN} == "__msg_name__" ]] ; then
+  PN=$(basename "$(pwd)")
+fi
+PV=$(json_value version)
+PVR="${PV}.${rev}"
+P="${PN}-${PVR}"
+
+rm -rf "${P}"
+mkdir "${P}"
+
+while read line ; do
+  [[ ${line} == */* ]] && mkdir -p "${P}/${line%/*}"
+  ln "${line}" "${P}/${line}"
+done < <(sed 's:#.*::' manifest.files)
+cp Makefile manifest.files manifest.json "${P}/"
+
+make -C "${P}" -j min
+while read line ; do
+  mv -v "${line}" "${line%.min}"
+done < <(find "${P}" -name '*.min')
+rm "${P}"/{manifest.files,Makefile}
+
+sed -i \
+  -e '/"version"/s:"[^"]*",:"'${PVR}'",:' \
+  "${P}/manifest.json"
+
+zip="${P}.zip"
+rm -f "${zip}"
+zip -r "${zip}" "${P}"
+rm -rf "${P}"
+du -b "${zip}"
diff --git a/manifest.files b/manifest.files
new file mode 100644 (file)
index 0000000..94c714c
--- /dev/null
@@ -0,0 +1,5 @@
+background.html
+background.js
+click_all.js
+icon-128x128.png
+icon-96x96.png
diff --git a/manifest.json b/manifest.json
new file mode 100644 (file)
index 0000000..023c2df
--- /dev/null
@@ -0,0 +1,27 @@
+{
+  "manifest_version": 2,
+  "minimum_chrome_version": "22",
+  "name": "Chromium Waterfall Job Canceler",
+  "version": "0.2",
+  "description": "Cancel most of the pending jobs on the active page.",
+  "icons": {
+    "128": "icon-128x128.png"
+  },
+  "page_action": {
+    "default_title": "Canceler"
+  },
+  "background": {
+    "persistent": false,
+    "page": "background.html"
+  },
+  "permissions": [
+    "alarms",
+    "storage",
+    "tabs",
+    "webNavigation",
+    "https://uberchromegw.corp.google.com/*",
+    "http://uberchromegw.corp.google.com/*",
+    "https://chromegw.corp.google.com/*",
+    "http://chromegw.corp.google.com/*"
+  ]
+}
diff --git a/pngcrush.sh b/pngcrush.sh
new file mode 100755 (executable)
index 0000000..d7aec69
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh -xe
+# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+pngcrush -e .png.new *.png
+for png in *.png.new ; do
+  mv ${png} ${png%.new}
+done