From 55314fcfd1c8ab53d400217d0873e236a20d9b34 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 28 Feb 2016 14:39:57 -0500 Subject: [PATCH] initial code --- Makefile | 38 +++++++++++++++++++++++++ background.html | 8 ++++++ background.js | 29 ++++++++++++++++++++ click_all.js | 47 +++++++++++++++++++++++++++++++ icon-128x128.png | Bin 0 -> 4239 bytes icon-96x96.png | Bin 0 -> 3146 bytes icon.svg | 10 +++++++ makedist.sh | 70 +++++++++++++++++++++++++++++++++++++++++++++++ manifest.files | 5 ++++ manifest.json | 27 ++++++++++++++++++ pngcrush.sh | 9 ++++++ 11 files changed, 243 insertions(+) create mode 100644 Makefile create mode 100644 background.html create mode 100644 background.js create mode 100644 click_all.js create mode 100644 icon-128x128.png create mode 100644 icon-96x96.png create mode 100644 icon.svg create mode 100755 makedist.sh create mode 100644 manifest.files create mode 100644 manifest.json create mode 100755 pngcrush.sh diff --git a/Makefile b/Makefile new file mode 100644 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 index 0000000..1b4d9f5 --- /dev/null +++ b/background.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/background.js b/background.js new file mode 100644 index 0000000..6eaae37 --- /dev/null +++ b/background.js @@ -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 index 0000000..e4c921d --- /dev/null +++ b/click_all.js @@ -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 index 0000000000000000000000000000000000000000..0d3807bf79e527f1cf0b5cf2ede3b46c6442d4a7 GIT binary patch literal 4239 zcmV;A5OD8_P)Px#32;bRa{vGh*8l(w*8xH(n|J^K00(qQO+^RZ1{o0w8O71FM*sj2AxT6*RCwC$ zT?uqm#TmZI%TCzBl9dohAdrATF>F~#02LJwL}e)|AX3EzQG&HC2(((k168y|YFz-e zh@RRa;!-vV1wlQnwTjdQ5fN?c(sMj*JuI*9d)$}aymyzGxifR;KHi-3p96V!=AVE5 zxpV)0G)+(o+JJ34;m|n(*IIV|*PA1QU%x)Wv?G24=>H!TGwsL&hKEcCF#O({X5$0V zgV_8Qi#__GZuuE@zgrJbU){0gLB|0IX|`l*&~6ZteIaHBGy`aMooxnb)y74Bn00v( z$pEIUj&KIz-bOC%3mfc<-Avt)49A^kw~&q-$B7$`o5t}?wBx(YZ?nP!tX@)K`heNL z&BzEky-ZFV@pOP9%MC>EDqEig$;nA11AJ?_jm_9bdLD#-oH`~yrgLU`GVv>&Eb=U< zBYazvc%3cv6h{QtQ;_!K76WOi$-&>Otcw2ob54jaVc5$tuy9T((+)i5w2c9MOWW8Y z|8oBb%f91Bbu~VlW<=gdf;IEkQ6U@6;>bbjfPfwmtB zk}a zx;~oMu_AZalqp;l-}JQPU`b)76Sd#+mcC~?AS~A6xg8?d-K%&bZ7)+0VO5yy;E{yta5q$HvLzzBStdnTzaNxySrY~JppSCUi&MI$9HHnr7|G94j^XE3Y-}yD2 zjK80>LcTxp(8@c?O^;USOisvOePR&Fv7BT}J>~fxWbE6j?IZo@TsOHJ^Vjn3TYK4? zDM-J1X2_G0G-iRcWdeJi9!xaI=X)BtO2ikt93%{24N2d(HVuoJz-KfQ7%?O#=Gnt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%Ti)_p=H|m)0h0xM!9r_&{1hm}DiRp#@_RL;ExEVOe z|200l@3GW2 zOtq_&WnqtCI*uu#Dbe1dne7zoZ5hNw@Vi(Ug?o)V)(nhzf+#i+C;{-~oPFWSdTv%SPx+le zcElnUra;rMewqJm?OD@$#EtN0f3=4%pP-yziFIY;KAnPx@D3l)m;i10v27JhDk0So z9Yg>EX5kfFSmAa)15McR6{!|JRnZOs6PpgMGaJf9q28$;n;L(-P= z7qrSAs_!GE)&1Gt5zKKMQ~>INI%RlXI=44VU1wyrt~oSAAB1iO=M5FAb%yGWVvbq^Sh zPB=^x{$dgVaFYz8Ar78iA@7zZ8aYQ4@TO6CTIeVI3|m)@EeMOvMGf;OOYlaD;T{Vp zqtbbR74M%KMe`g2B_%fg-#SB)1DR?-kSm4=;}O6Y6J)Md$O3LiP|4`XNA zv3Enzz((Vl5U&h_QqGxPAb1pPRpD#^@#O*VH(UaQle3dg!~If~80)8ydn2A0g)khV zF%F#03bA`M1cl=yb#$Jg@ba(>U_KYw{kQ=%;%II7kA-ZSO<-EA87;mhHR=nUvH)7N zFME z2K9P?!mpEc&MMXI>(3L_PZj(=;H>ygL5WIl=p(9`gouPe+Zx=F6I1kf-KEnTbX zA|03-&nxm!lL7F+68(|m0^kHAfb@V2qk~J*g+F(t1K=$OJV^?_-Uv7)*f&JD7=`Et z@gjHu7egG@x()2HNOimmHR$>4XY`Z`YAK6f9jG+t-QKg67l8$Kh7pG;*TRov)&&S; z0$*T~`B + + + + + + + + + \ No newline at end of file diff --git a/makedist.sh b/makedist.sh new file mode 100755 index 0000000..9ecf0bf --- /dev/null +++ b/makedist.sh @@ -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 + +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 index 0000000..94c714c --- /dev/null +++ b/manifest.files @@ -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 index 0000000..023c2df --- /dev/null +++ b/manifest.json @@ -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 index 0000000..d7aec69 --- /dev/null +++ b/pngcrush.sh @@ -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 -- 2.39.5