changes
authorJoerg Jaspert <joerg@debian.org>
Thu, 4 Dec 2014 10:41:02 +0000 (11:41 +0100)
committerJoerg Jaspert <joerg@debian.org>
Thu, 4 Dec 2014 10:41:02 +0000 (11:41 +0100)
.conkerorrc/025-contentPolicy.js [deleted file]
.conkerorrc/060-webjumps.js
.conkerorrc/065-bookmark-manipulate.js

diff --git a/.conkerorrc/025-contentPolicy.js b/.conkerorrc/025-contentPolicy.js
deleted file mode 100644 (file)
index b9a7128..0000000
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
-  Simple Content-Policy management for Conkeror.
-  It uses mozilla's storage service.
-
-  (C) Copyright 2014 thorkill
-  BSD License
-*/
-
-require("content-policy.js");
-
-Components.utils.import("resource://gre/modules/Services.jsm");
-Components.utils.import("resource://gre/modules/FileUtils.jsm");
-
-// runtime copy of the db
-// we need it because contentPolicy.shouldLoad can not be blocked
-content_policy_jscript_actions = ({});
-
-// content policy
-function block_sniff (content_type, content_location) {
-    jsdump("block sniff: " + content_type + " : " + content_location.spec);
-    return content_policy_accept;
-}
-
-function block_flash (content_type, content_location) {
-    var Y = content_policy_accept, N = content_policy_reject;
-
-    var action = ({ "homestarrunner.com":Y }
-                  [content_location.host] || N);
-
-    if (action == N)
-        jsdump("blocked content: "+content_type+" : "+content_location.spec);
-
-    return action;
-}
-
-function block_image (content_type, content_location) {
-    var Y = content_policy_accept, N = content_policy_reject;
-
-    var action = ({ "homestarrunner.com" : N }
-                  [content_location.host] || Y);
-
-    if (action == N)
-        jsdump("blocked content: "+content_type+" : "+content_location.spec);
-
-    return action;
-}
-
-// reload permissions on whitelist/blacklist
-function _reload_permissions() {
-    content_policy_jscript_actions = ({});
-    get_permissions(init_permissions);
-}
-
-// callback function which fills the
-// action-list
-function init_permissions(host, value) {
-    jsdump("Adding: "+host +" : " + value);
-    if (value == 't')
-        content_policy_jscript_actions[host] = content_policy_accept;
-    else
-        content_policy_jscript_actions[host] = content_policy_reject;
-}
-
-// here we handle the javascript content filtering
-function block_script (content_type, content_location, request_origin) {
-    var Y = content_policy_accept, N = content_policy_reject;
-
-    var action = (content_policy_jscript_actions[content_location.host] || N);
-    jsdump(content_type + " : " + content_location.host + " : "+ action + " / " + request_origin.host);
-
-    if (action == N)
-        jsdump("blocked JS: "+content_location.spec);
-
-    return action;
-}
-
-// 1
-//content_policy_bytype_table.other = block_sniff;
-// 2
-content_policy_bytype_table.script = block_script;
-// 3
-//content_policy_bytype_table.image = block_image;
-// 4
-//content_policy_bytype_table.stylesheet = block_sniff;
-// 5
-content_policy_bytype_table.object = block_flash;
-// 6
-//content_policy_bytype_table.document = block_sniff;
-// 7
-//content_policy_bytype_table.subdocument = block_sniff;
-// 9
-//content_policy_bytype_table.xbl = block_sniff;
-// 10
-//content_policy_bytype_table.ping = block_sniff;
-// 11
-//content_policy_bytype_table.xmlhttprequest = block_sniff;
-// 12
-//content_policy_bytype_table.object_subrequest = block_sniff;
-// 13
-//content_policy_bytype_table.dtd = block_sniff;
-// 14
-//content_policy_bytype_table.font = block_sniff;
-// 15
-//content_policy_bytype_table.media = block_sniff;
-
-/* ---- start of db-part ---- */
-
-function get_permissions(aCallBack) {
-    jsdump("Load content-policy rules");
-    dbConn = initDB();
-    var r = dbConn.createStatement("SELECT host ,allowjs FROM permissions");
-
-    let tempval = r.executeAsync({
-        handleResult: function(aResultSet) {
-            for(let row = aResultSet.getNextRow();
-                row;
-                row = aResultSet.getNextRow()) {
-                host = row.getResultByName("host");
-                value = row.getResultByName("allowjs");
-                aCallBack(host, value);
-            }
-        },
-
-        handleError: function(aError) {
-            jsdump("Error: " + aError.message);
-            return false;
-        },
-
-        handleCompletion: function(aReason) {
-            if (aReason != Components.interfaces.mozIStorageStatementCallback.REASON_FINISHED)
-                jsdump("Query canceled or aborted!");
-            return false;
-        }
-    });
-    closeDB();
-    return tempval;
-}
-
-function allow_js_host(host) {
-    jsdump("whitelist: " + host);
-    if (host == null)
-        return;
-
-    dbConn = initDB();
-    var r = dbConn.createStatement("INSERT OR REPLACE INTO permissions (host, allowjs) VALUES(:host, 't')");
-    r.params.host=host;
-    r.executeAsync();
-    closeDB();
-}
-
-function deny_js_host(host) {
-    jsdump("blacklist: " + host);
-    if (host == null)
-        return;
-
-    dbConn = initDB();
-    var r = dbConn.createStatement("INSERT OR REPLACE INTO permissions (host, allowjs) VALUES(:host, 'f')");
-    r.params.host=host;
-    r.executeAsync();
-    closeDB();
-}
-
-function initDB() {
-    let file = FileUtils.getFile("ProfD", ["cp_jscript.sqlite"]);
-    let dbConn = Services.storage.openDatabase(file);
-
-    if (!dbConn.tableExists("prefs")) {
-        jsdump("Table pref not found");
-        dbConn.executeSimpleSQL("CREATE TABLE prefs (pref TEXT UNIQUE NOT NULL, value TEXT)");
-        var r = dbConn.createStatement("INSERT INTO prefs (pref, value) VALUES (:pref, :value)");
-        r.params.pref="version";
-        r.params.value="0.1";
-        r.executeAsync();
-    }
-
-    if (!dbConn.tableExists("permissions")) {
-        jsdump("Tables not found");
-        dbConn.executeSimpleSQL("CREATE TABLE permissions (host TEXT UNIQUE NOT NULL, allowjs BOOLEAN)");
-    }
-    return dbConn;
-}
-
-function closeDB(dbConn) {
-    if (dbConn)
-        dbConn.close()
-}
-/* ---- end of db-part ---- */
-
-function uri2basedomain(aURI) {
-    try {
-        var az = make_uri(aURI);
-        return az.host;
-    } catch (e) {
-        return null;
-    }
-    return aURI;
-}
-
-// ContentPolicy JavaScript completer
-// iterates over javascript resources and shows it's permissions
-function cp_js_completer(B) {
-    var completions = B;
-    var get_string = function (x) x;
-    var get_description = function (x) {
-        x = uri2basedomain(x);
-        var n = content_policy_jscript_actions[x];
-        if (n == 1)
-            return x + ": whitelisted";
-        else if (n == -1)
-            return x + ": blacklisted";
-        else
-            return "";
-        };
-
-    var get_value = function (x) "value: " + x;
-    var get_icon = null;
-    var arr;
-
-    var completer = function (input, pos, conservative) {
-        //dumpln("Mine I: " + input + ", P: "+pos+", C:" + conservative);
-        if (input.length == 0 && conservative)
-            return undefined;
-
-        var words = input.toLowerCase().split(" ");
-
-        var data = arr;
-
-        return {count: data.length,
-                index_of:  function (x) data.indexOf(x),
-                get_string: function (i) get_string(data[i]),
-                get_description : function (i) get_description(data[i]),
-                get_input_state: function (i) [get_string(data[i])],
-                get_value: function (i) (get_value ? get_value(data[i]) : data[i]),
-                get_icon: function (i) (get_icon ? get_icon(data[i]) : null)
-               };
-    };
-
-    completer.refresh = function () {
-        var data = [];
-
-        entries = B.document.getElementsByTagName('script');
-        _unique_scripts = {};
-
-        for (i = 0 ; i < entries.length ; i++)
-        {
-            var src = entries[i].src;
-            // this is the case where <script> is embedded into html code
-            if (src == null || src == "")
-                src = B.document.baseURI;
-
-            if (_unique_scripts[src])
-                continue;
-
-            _unique_scripts[src] = true;
-            data.push(src);
-        }
-        arr = data;
-    };
-    completer.refresh();
-    return completer;
-}
-
-function cp_js_show (window, message) {
-    host = uri2basedomain(message);
-    if (host in content_policy_jscript_actions) {
-        if (content_policy_jscript_actions[host] == content_policy_accept)
-           deny_js_host(host);
-        else
-            allow_js_host(host);
-    }  else {
-        // default is to whitelist a host
-        // just because I do not permit JS per default
-        allow_js_host(host);
-    }
-    _reload_permissions();
-}
-
-interactive("cp-js-show",
-            "Show JavaScript content of current buffer with information from content policy DB.",
-            function (I) {
-                cp_js_show(
-                    I.window,
-                    (yield I.minibuffer.read($prompt = "Toggle CP-JS for: ",
-                                             $completer = cp_js_completer(I.window.buffers.current))));
-            });
-
-interactive("blacklist-js", "Blacklists current URI for javascript usage.",
-            function(I) {
-                deny_js_host(I.buffer.current_uri.host);
-                _reload_permissions();
-            });
-
-interactive("whitelist-js", "Whitelists current URI for javascript usage.",
-            function(I) {
-                allow_js_host(I.buffer.current_uri.host);
-                _reload_permissions();
-            });
-
-/**
- * content_policy_status_widget shows if the content policy is enabled.
- */
-function content_policy_status_widget (window) {
-    this.class_name = "content-policy-status-widget";
-    text_widget.call(this, window);
-    // Update only if something happens ...
-    this.add_hook("select_buffer_hook");
-    this.add_hook("create_buffer_hook");
-    this.add_hook("kill_buffer_hook");
-    this.add_hook("move_buffer_hook");
-    this.add_hook("current_content_buffer_location_change_hook");
-    this.add_hook("current_content_buffer_focus_change_hook");
-    this.add_hook("current_special_buffer_generated_hook");
-}
-
-content_policy_status_widget.prototype = {
-    constructor: content_policy_status_widget,
-    __proto__: text_widget.prototype,
-    update: function () {
-        if (content_policy_listener.enabled)
-            this.view.text = ("[+]");
-        else
-            this.view.text = ("[-]");
-    }
-};
-
-/**
- * Define some hooks
- */
-add_hook("content_policy_hook", content_policy_bytype);
-add_hook("mode_line_hook", mode_line_adder(content_policy_status_widget));
-add_hook("init_hook", get_permissions(init_permissions));
index dd68f1f..cc11098 100644 (file)
@@ -49,4 +49,4 @@ wikipedia_enable_didyoumean = true;
 define_wikipedia_webjumps("en", "de");
 
 define_webjump("ris", "http://bahn.de/ris");
-define_webjump("cm", "javascript:with(document)(head.appendChild(createElement('script')).src='//cookiemaster.co.uk/b?c='+Date.now())._")
+define_webjump("cm", "javascript:with(document)(head.appendChild(createElement('script')).src='//cookiemaster.co.uk/b?c='+Date.now())._");
index cbe6433..1f7b099 100644 (file)
@@ -28,3 +28,24 @@ interactive("bookmark-remove", "Remove a bookmark",
             $browser_object = browser_object_bookmarks
            );
 
+interactive("owncloudbm", "Add bookmark to owncloud",
+            function owncloudbm (I, prompt) {
+                check_buffer(I.buffer, content_buffer);
+                let createurl = 'https://owncloud.ganneff.de/index.php/apps/bookmarks/addBm.php?output=popup&url=' +
+                    encodeURIComponent(
+                        load_spec_uri_string(
+                            load_spec(I.buffer.top_frame))) +
+                    '&title=' +
+                    encodeURIComponent(
+                        yield I.minibuffer.read(
+                            $prompt = "name (required): ",
+                            $initial_value = I.buffer.title));
+                try {
+                    var document= I.buffer.document;
+                    browser_object_follow(I.buffer, OPEN_NEW_BUFFER, createurl);
+                } catch (e) { }
+            });
+
+define_key(content_buffer_normal_keymap, "* q", "owncloudbm");
+
+// javascript:(function(){var%20a=window,b=document,c=encodeURIComponent,e=c(document.title),d=a.open('https://owncloud.ganneff.de/index.php/apps/bookmarks/addBm.php?output=popup&url='+c(b.location)+'&title='+e,'bkmk_popup','left='+((a.screenX||a.screenLeft)+10)+',top='+((a.screenY||a.screenTop)+10)+',height=400px,width=550px,resizable=1,alwaysRaised=1');a.setTimeout(function(){d.focus()},300);})();