From ed5d80d9195e99a7ead8562e29a036adeff74407 Mon Sep 17 00:00:00 2001 From: Maciej Sobkowski Date: Thu, 2 Jul 2015 16:18:49 +0200 Subject: Added config for firefox/pentadactyl --- pentadactyl/.pentadactyl/colors/zenburn.penta | 56 +++ .../.pentadactyl/plugins/http-headers-dev.js | 151 +++++++ pentadactyl/.pentadactyl/plugins/noscript-dev.js | 477 +++++++++++++++++++++ 3 files changed, 684 insertions(+) create mode 100644 pentadactyl/.pentadactyl/colors/zenburn.penta create mode 100644 pentadactyl/.pentadactyl/plugins/http-headers-dev.js create mode 100644 pentadactyl/.pentadactyl/plugins/noscript-dev.js (limited to 'pentadactyl/.pentadactyl') diff --git a/pentadactyl/.pentadactyl/colors/zenburn.penta b/pentadactyl/.pentadactyl/colors/zenburn.penta new file mode 100644 index 0000000..ae942f4 --- /dev/null +++ b/pentadactyl/.pentadactyl/colors/zenburn.penta @@ -0,0 +1,56 @@ +" FileName: zenburn.penta +" Author: zouyang +" Last Updated: Sat 08 Jan 2011 09:46:19 PM CST +hi Cmd background-color:#313633; font-size:9pt; +hi -a StatusLineNormal color:#ccdc90; background-color:#313633 !important; margin-bottom:-2px; font-size:9pt; + +hi -l StatusLineNormal StatusLineSecure color:#87af87; +hi -l StatusLineNormal StatusLineBroken color:#ffa0a0; +hi -l StatusLineNormal StatusLineExtended color:#a0ffa0; +hi -a String color:#cc9393; +hi -a Boolean color:#dca3a3; +hi -a Function color:#efef8f; +hi -a Number color:#8cd0d3; +hi WarningMsg color:#ffffff; background-color:#333333 !important; font-weight:bold; +hi -l WarningMsg StatusWarningMsg +hi -l WarningMsg CmdWarningMsg +hi ErrorMsg color:#80d4aa !important; background-color:#2f2f2f !important; font-weight:bold; font-size:9pt; +hi -l ErrorMsg StatusErrorMsg +hi -l ErrorMsg CmdErrorMsg +hi -a ModeMsg color:#ffcfaf; background-color:transparent !important; +hi -l ModeMsg StatusModeMsg +hi -l ModeMsg CmdModeMsg +hi -a MoreMsg color:#ffffff !important; background-color:inherit !important; font-weight:bold; +hi -l MoreMsg StatusMoreMsg +hi -l MoreMsg CmdMoreMsg +hi -l Cmd InfoMsg color:#cccccc !important; +hi -l InfoMsg StatusInfoMsg +hi -l InfoMsg CmdInfoMsg +hi Question color:#ffffff !important; background-color:inherit !important; font-weight:bold; +hi -l Question StatusQuestion +hi -l Question CmdQuestion +hi -a Tag color:#e89393; font-weight:bold; +hi -a CmdLine font-weight:normal; padding:0 3px; +hi -a NonText color:#404040; font-weight:bold; +hi Normal color:#dcdccc !important; background-color:#313633 !important; font-size:9pt; +hi -l Normal CmdNormal +hi -l Normal StatusNormal +hi -a Title color:#efefef; background-color:inherit; font-weight:bold; +hi -a CompItem[selected] color:#cbecd0; background-color:#2c302d !important; +hi -a CompMore margin-bottom:0;margin-top:.5ex; +hi -a CompMore::after content:"\02c7" +hi -a CompLess margin-top:.5ex;margin-bottom:1ex; +hi -a CompLess::after content:"\02c6" +hi -a CompTitle color:lightblue; background-color:transparent; +hi -a CompTitleSep background:-moz-linear-gradient(60deg, lightblue, white); height:1px; +hi -a Filter font-style:italic; text-decoration:underline; +hi -a Keyword color:#f0dfaf; font-weight:bold; +hi -a URL text-decoration:none; color:#9ECE9E; background-color:inherit; +hi -a URL:hover text-decoration:underline; cursor: pointer; +hi -a LineNr color:#9fafaf; background-color:#262626; + +" plugin styles +hi -a BufTabSelected color:#2e3330; background-color:#88b090; padding:0 4px; +hi -a BufTabs margin:0 4px; overflow:hidden; +hi -a BufTab padding:0 2px; +" vim: set ft=pentadactyl:ts=4:sw=4:tw=0: diff --git a/pentadactyl/.pentadactyl/plugins/http-headers-dev.js b/pentadactyl/.pentadactyl/plugins/http-headers-dev.js new file mode 100644 index 0000000..a2e4288 --- /dev/null +++ b/pentadactyl/.pentadactyl/plugins/http-headers-dev.js @@ -0,0 +1,151 @@ +"use strict"; +isGlobalModule = true; + +var INFO = +["plugin", { name: "http-headers", + version: "0.6", + href: "http://dactyl.sf.net/pentadactyl/plugins#http-headers-plugin", + summary: "HTTP header info", + xmlns: "dactyl" }, + ["author", { email: "maglione.k@gmail.com" }, + "Kris Maglione"], + ["license", { href: "http://opensource.org/licenses/mit-license.php" }, + "MIT"], + ["project", { name: "Pentadactyl", "min-version": "1.0" }], + + ["p", {}, + "Adds request and response headers to the :pageinfo ", + "command, with the keys ", ["em", {}, "h"], " and ", ["em", {}, "H"], " respectively. ", + "See also ", ["o", {}, "pageinfo"], "."], + + ["example", {}, ["ex", {}, ":pageinfo hH"]]]; + +var { Buffer } = require("buffer"); + +var Controller = Class("Controller", XPCOM(Ci.nsIController), { + init: function (command, data) { + this.command = command; + this.update(data); + }, + get wrappedJSObject() this, + supportsCommand: function (cmd) cmd === this.command +}); + +var HttpObserver = Class("HttpObserver", + XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference, Ci.nsIWebProgressListener]), { + + init: function init() { + util.addObserver(this); + }, + + cleanup: function cleanup() { + this.observe.unregister(); + }, + + extractHeaders: function extractHeaders(request, type) { + let major = {}, minor = {}; + request.QueryInterface(Ci.nsIHttpChannelInternal)["get" + type + "Version"](major, minor); + + let headers = [[type.toUpperCase(), "HTTP/" + major.value + "." + minor.value]]; + request["visit" + type + "Headers"]({ + visitHeader: function (header, value) { + headers.push([header, value]); + } + }); + return headers; + }, + + getHeaders: function getHeaders(win, request) { + request.QueryInterface(Ci.nsIChannel); + + let headers = overlay.getData(win.document, "headers", Object); + if ("response" in headers) + return; + + if (win && /^https?$/.test(request.URI.scheme)) { + if (request instanceof Ci.nsIHttpChannel) + request.QueryInterface(Ci.nsIHttpChannel); + else { + request.QueryInterface(Ci.nsIMultiPartChannel); + request.baseChannel.QueryInterface(Ci.nsIHttpChannel); + } + + headers.request = this.extractHeaders(request, "Request"); + headers.request[0][1] = request.requestMethod + " " + + request.URI.path + " " + headers.request[0][1]; + + try { + headers.response = this.extractHeaders(request, "Response"); + headers.response[0][1] += " " + request.responseStatus + " " + + request.responseStatusText; + } + catch (e) {} + + let controller = this.getController(win); + if (controller) + win.controllers.removeController(controller); + win.controllers.appendController(Controller("dactyl-headers", { headers: headers, url: win.document.documentURI })); + } + }, + + observers: { + "http-on-examine-response": util.wrapCallback(function onExamineResponse(request, data) { + request.QueryInterface(Ci.nsIChannel).QueryInterface(Ci.nsIHttpChannel).QueryInterface(Ci.nsIRequest); + + if (request.loadFlags & request.LOAD_DOCUMENT_URI) { + try { + var win = request.notificationCallbacks.getInterface(Ci.nsIDOMWindow); + } + catch (e) { + return; + } + this.getHeaders(win, request); + try { + webProgress.addProgressListener(this, Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT); + } + catch (e) {} + } + }) + }, + + onStateChange: util.wrapCallback(function(webProgress, request, stateFlags, status) { + if ((stateFlags & this.STATE_START) && (stateFlags & this.STATE_IS_DOCUMENT)) + this.getHeaders(webProgress.DOMWindow, request); + else if ((stateFlags & this.STATE_STOP) && (stateFlags & this.STATE_IS_DOCUMENT)) { + this.getHeaders(webProgress.DOMWindow, request); + try { + webProgress.removeProgressListener(this); + } catch (e) {} + } + }), + + getController: function getController(win) { + for (let i of util.range(0, win.controllers.getControllerCount())) { + let controller = win.controllers.getControllerAt(i); + if (controller.supportsCommand("dactyl-headers") && controller.wrappedJSObject instanceof Controller) + return controller.wrappedJSObject; + } + } +}); + +let observer = HttpObserver(); +let onUnload = observer.closure.cleanup; + +function iterHeaders(buffer, type) { + let win = buffer.focusedFrame; + let store = win.document[overlay.id]; + if (!store || !store.headers) + store = observer.getController(win); + + if (store) + for (let [k, v] of values(store.headers[type] || [])) + yield [k, v]; +} + +iter({ h: "Request", H: "Response" }).forEach(function ([key, name]) + Buffer.addPageInfoSection(key, name + " Headers", function (verbose) { + if (verbose) + return iterHeaders(this, name.toLowerCase()) + })); + +/* vim:se sts=4 sw=4 et: */ diff --git a/pentadactyl/.pentadactyl/plugins/noscript-dev.js b/pentadactyl/.pentadactyl/plugins/noscript-dev.js new file mode 100644 index 0000000..e0f3161 --- /dev/null +++ b/pentadactyl/.pentadactyl/plugins/noscript-dev.js @@ -0,0 +1,477 @@ +/* + * Copyright ©2010-2014 Kris Maglione + * Distributable under the terms of the MIT license. + * + * Documentation is at the tail of this file. + */ +"use strict"; + +if (!("noscriptOverlay" in window)) { + if (!userContext.noscriptIgnoreMissing) + dactyl.echoerr("This plugin requires the NoScript add-on."); + throw Finished(); +} + +/* + * this.globalJS ? !this.alwaysBlockUntrustedContent || !this.untrustedSites.matches(s) + * : this.jsPolicySites.matches(s) && !this.untrustedSites.matches(s) && !this.isForbiddenByHttpsStatus(s)); + */ + +function getSites() { + // This logic comes directly from NoScript. To my mind, it's insane. + const ns = services.noscript; + const global = options["script"]; + const groups = { allowed: ns.jsPolicySites, temp: ns.tempSites, untrusted: ns.untrustedSites }; + const show = RealSet(options["noscript-list"]); + const sites = window.noscriptOverlay.getSites(); + + const blockUntrusted = global && ns.alwaysBlockUntrustedContent; + + let res = []; + for (let site of array.iterValues(Array.concat(sites.topSite, sites))) { + let ary = []; + + let untrusted = groups.untrusted.matches(site); + let matchingSite = null; + if (!untrusted) + matchingSite = groups.allowed.matches(site) || blockUntrusted && site; + + let enabled = Boolean(matchingSite); + if (site == sites.topSite && !ns.dom.getDocShellForWindow(content).allowJavascript) + enabled = false; + + let hasPort = /:\d+$/.test(site); + + if (enabled && !global || untrusted) { + if (!enabled || global) + matchingSite = untrusted; + + if (hasPort && ns.ignorePorts) + if (site = groups.allowed.matches(site.replace(/:\d+$/, ""))) + matchingSite = site; + ary.push(matchingSite); + } + else { + if ((!hasPort || ns.ignorePorts) && (show.has("full") || show.has("base"))) { + let domain = !ns.isForbiddenByHttpsStatus(site) && ns.getDomain(site); + if (domain && ns.isJSEnabled(domain) == enabled) { + ary = util.subdomains(domain); + if (!show.has("base") && ary.length > 1) + ary = ary.slice(1); + if (!show.has("full")) + ary = ary.slice(0, 1); + } + } + + if (show.has("address") || ary.length == 0) { + ary.push(site); + + if (hasPort && ns.ignorePorts) { + site = site.replace(/:\d+$/, ""); + if (!groups.allowed.matches(site)) + ary.push(site); + } + } + } + res = res.concat(ary); + } + + let seen = RealSet(); + return res.filter(function (h) { + let res = !seen.has(h); + seen.add(h); + return res; + }); +} +function getObjects() { + let sites = noscriptOverlay.getSites(); + let general = [], specific = []; + for (let group of values(sites.pluginExtras)) + for (let obj of array.iterValues(group)) { + if (!obj.placeholder && (ns.isAllowedObject(obj.url, obj.mime) || obj.tag)) + continue; + specific.push(obj.mime + "@" + obj.url); + general.push("*@" + obj.url); + general.push("*@" + obj.site); + } + sites = buffer.allFrames().map(function (f) f.location.host); + for (let filter of values(options["noscript-objects"])) { + let host = util.getHost(util.split(filter, /@/, 2)[1]); + if (sites.some(function (s) s == host)) + specific.push(filter); + } + let seen = RealSet(); + return specific.concat(general).filter(function (site) { + let res = !seen.has(site); + seen.add(site); + return res; + }); +} + +var onUnload = overlay.overlayObject(gBrowser, { + // Extend NoScript's bookmarklet handling hack to the command-line + // Modified from NoScript's own wrapper. + loadURIWithFlags: function loadURIWithFlags(url) { + let args = arguments; + function load() loadURIWithFlags.superapply(gBrowser, args); + + if (!commandline.command || !util.isDactyl(Components.stack.caller)) + return load(); + + try { + for (let [cmd, args] of commands.parseCommands(commandline.command)) + var origURL = args.literalArg; + + let isJS = function isJS(url) /^(?:data|javascript):/i.test(url); + let allowJS = prefs.get("noscript.allowURLBarJS", true); + + if (isJS(origURL) && allowJS) { + if (services.noscript.executeJSURL(origURL, load)) + return; + } + else if (url != origURL && isJS(url)) { + if(services.noscript.handleBookmark(url, load)) + return; + } + } + catch (e) { + util.reportError(e); + } + return load(); + } +}); + +highlight.loadCSS(literal(/* + NoScriptAllowed color: green; + NoScriptBlocked color: #444; font-style: italic; + NoScriptTemp color: blue; + NoScriptUntrusted color: #c00; font-style: italic; +*/)); + +let groupProto = {}; +["temp", "jsPolicy", "untrusted"].forEach(function (group) + memoize(groupProto, group, function () services.noscript[group + "Sites"].matches(this.site))); +let groupDesc = { + NoScriptTemp: "Temporarily allowed", + NoScriptAllowed: "Allowed permanently", + NoScriptUntrusted: "Untrusted", + NoScriptBlocked: "Blocked" +}; + +function splitContext(context, list) { + for (let [name, title, filter] of values(list)) { + let ctxt = context.split(name); + ctxt.title = [title]; + ctxt.filters.push(filter); + } +} + +completion.noscriptObjects = function (context) { + let whitelist = options.get("noscript-objects").set; + context = context.fork(); + context.compare = CompletionContext.Sort.unsorted; + context.generate = getObjects; + context.keys = { + text: util.identity, + description: function (key) whitelist.has(key) ? "Allowed" : "Forbidden" + }; + splitContext(context, getObjects, [ + ["forbidden", "Forbidden objects", function (item) !whitelist.has(item.item)], + ["allowed", "Allowed objects", function (item) whitelist.has(item.item)]]); +}; +completion.noscriptSites = function (context) { + context.compare = CompletionContext.Sort.unsorted; + context.generate = getSites; + context.keys = { + text: util.identity, + description: function (site) groupDesc[this.highlight] + + (this.groups.untrusted && this.highlight != "NoScriptUntrusted" ? " (untrusted)" : ""), + + highlight: function (site) this.groups.temp ? "NoScriptTemp" : + this.groups.jsPolicy ? "NoScriptAllowed" : + this.groups.untrusted ? "NoScriptUntrusted" : + "NoScriptBlocked", + groups: function (site) ({ site: site, __proto__: groupProto }) + }; + splitContext(context, [ + ["normal", "Active sites", function (item) item.groups.jsPolicy || !item.groups.untrusted], + ["untrusted", "Untrusted sites", function (item) !item.groups.jsPolicy && item.groups.untrusted]]); + context.maxItems = 100; +} + +services.add("noscript", "@maone.net/noscript-service;1"); + +var PrefBase = "noscript."; +var Pref = Struct("text", "pref", "description"); +let prefs = { + forbid: [ + ["bookmarklet", "forbidBookmarklets", "Forbid bookmarklets"], + ["collapse", "collapseObject", "Collapse forbidden objects"], + ["flash", "forbidFlash", "Block Adobe® Flash® animations"], + ["fonts", "forbidFonts", "Forbid remote font loading"], + ["frame", "forbidFrames", "Block foreign elements"], + ["iframe", "forbidIFrames", "Block foreign