MozillaZine

keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
morat
 
Posts: 3483
Joined: February 3rd, 2009, 6:29 pm

Post Posted January 8th, 2019, 5:57 am

@onix

Try these:

Code: Select all
var element = document.getElementById("xpunge_multi_disable_menuitem");
xpunge_mu_doMenuActionCall(element);

Code: Select all
xpunge_doMultiple();

Xpunge
http://addons.thunderbird.net/thunderbird/addon/1279

onix
 
Posts: 45
Joined: March 21st, 2007, 10:22 am

Post Posted January 15th, 2019, 9:55 pm

Thanks, morat! I chose the simpler one --
Code: Select all
xpunge_doMultiple();
and it worked!

What is the best way to figure these obscure commands out?

morat
 
Posts: 3483
Joined: February 3rd, 2009, 6:29 pm

Post Posted January 16th, 2019, 6:59 am

@onix

You would have to know JavaScript and XUL to figure out the keyconfig code for the Xpunge request.

* chrome\content\xpunge_MessengerOverlay.xul

Code: Select all
<menuitem id="xpunge_multi_disable_menuitem"
  label="&xpunge.menu.multi.call.label;"
  oncommand="xpunge_mu_doMenuActionCall(this)"/>

* chrome\content\xpunge_Messenger_Multi.js

Code: Select all
function xpunge_mu_doMenuActionCall(elem) {
  xpunge_doMultiple();
}

JavaScript this
http://www.w3schools.com/js/js_this.asp

Wang Xiao Ming
 
Posts: 25
Joined: May 22nd, 2009, 7:10 am

Post Posted January 17th, 2019, 3:33 am

Is it possible to use keyconfig to change about:config values?
I want to toggle cleartype (gfx.font_rendering.cleartype_params.cleartype_level;-1) between 0 and -1.

morat
 
Posts: 3483
Joined: February 3rd, 2009, 6:29 pm

Post Posted January 17th, 2019, 4:42 am

@Wang Xiao Ming

Try this:

Code: Select all
var prefBranch = Components.classes["@mozilla.org/preferences-service;1"].
  getService(Components.interfaces.nsIPrefBranch);
var pref = "gfx.font_rendering.cleartype_params.cleartype_level";
var value = prefBranch.getIntPref(pref);
if (value === -1) prefBranch.setIntPref(pref, 0);
else prefBranch.setIntPref(pref, -1);

Wang Xiao Ming
 
Posts: 25
Joined: May 22nd, 2009, 7:10 am

Post Posted January 17th, 2019, 5:43 pm

Holy ****! that works perfectly. Thank you so much.

Now I am trying to disable cleartype only on pdf files automatically.

I am using this tampermonkey script:
Code: Select all
(function() {
    'use strict';
    var prefBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
    var pref = "gfx.font_rendering.cleartype_params.cleartype_level";
    prefBranch.setIntPref(pref, 0);
})();

which I want it to run just before the pdf is loaded (run at: document start) to disable cleartype, and then run another script to enable cleartype when the pdf finishes loading (run at: document idle). This is because unlike other pages, pdfs need reloading to apply current cleartype mode.
However the above script isn't working. It's not changing cleartype at all.
any suggestion very much welcome. my monitor is low res and rendering is pretty bad without cleartype on normal pages, and very bad on pdf with cleartype

morat
 
Posts: 3483
Joined: February 3rd, 2009, 6:29 pm

Post Posted January 17th, 2019, 6:31 pm

@Wang Xiao Ming

A tampermonkey script is untrusted content code. A keyconfig script is system privileged chrome code.

You can't access nsIPrefBranch interface with a tampermonkey script.

What app and version are you using?

The tampermonkey extension doesn't work in thunderbird. The keyconfig extension doesn't work in firefox.

Wang Xiao Ming
 
Posts: 25
Joined: May 22nd, 2009, 7:10 am

Post Posted January 18th, 2019, 1:52 pm

I am using Waterfox, a Firefox 56 updated mod.

Too bad tampermonkey won't work.
Out of keyconfig domain but I will mention that I suspect extensions can enable/disable cleartype using css. I have tested the following css with stylish without success:
Code: Select all
font-smooth: never;
-webkit-font-smoothing : none;

morat
 
Posts: 3483
Joined: February 3rd, 2009, 6:29 pm

Post Posted January 18th, 2019, 5:23 pm

@Wang Xiao Ming

Try the following tampermonkey script:

Code: Select all
(function () {

  "use strict";

  var style = document.createElement("style");
  style.type = "text/css";
  style.textContent = [
    "* { font-smooth: never !important; }",
    "* { -webkit-font-smoothing: none !important; }",
  ].join("\n");
  if (document.head) {
    document.head.appendChild(style);
  } else {
    document.documentElement.appendChild(style);
  }

})();

Wang Xiao Ming
 
Posts: 25
Joined: May 22nd, 2009, 7:10 am

Post Posted January 19th, 2019, 1:55 pm

Thanks morat,
I think the css code simply doesn't work unfortunately, at least on my firefox. Tested your code with tampermoneky as well as with stylish.
I have run out of ideas for now.. but at least there is your keyconfig script!

Bananasik
 
Posts: 12
Joined: November 7th, 2016, 3:10 am

Post Posted February 8th, 2019, 2:22 am

Hello again.

Need hide posts without images on imageboards and locally saved web pages from them, for quick look at page content

Found some code from already dead website autologgers

Code: Select all
  $(function() {
    if ($("#thre>table:has(td.rtd>a>img)").length > 0) {
      return $("#hdp>.hml:last-of-type").after($("<span>", {
        "class": "hml"
      }).append($("<a>", {
        text: "hide images",
        href: "javascript:void(0);",
        on: {
          click: function() {
            if ($("#thre>table:not(:has(td.rtd>a>img)):hidden").length === 0) {
              $("#thre>table:not(:has(td.rtd>a>img))").css("display", "none");
              return $(this).text("original look");
            } else {
              $("#thre>table:not(:has(td.rtd>a>img)):hidden").css("display", "");
              return $(this).text("hide images");
            }
          }
        }
      })));
    }
  });


Code: Select all
  noimg_del_f = function() {
    $("table.noimgtable").each(function(){
      if( !$(this).hasClass("deleted") ){
        $(this).css("display", dispdel_b?"none":"block");
      }
    });
    $("button#noimgbtn").text(dispdel_b?"show all":"images only")
    dispdel_b = !dispdel_b;
  }
  $("span").each(function(idx,elem){
    if(idx == 0){
      $("<button id='noimgbtn' onclick='noimg_del_f()' >images only</button>").insertAfter(this);
    }
  });



https://ufile.io/xoynt
https://ufile.io/9bwik
Web page with built in second script

http://may.2chan.net/id/res/300832.htm
Imageboard thread, to practice with.

Can keyconfig do that?

morat
 
Posts: 3483
Joined: February 3rd, 2009, 6:29 pm

Post Posted February 9th, 2019, 9:10 pm

@Bananasik

You can run a bookmarklet in the selected tab with the keyconfig extension.

More info: viewtopic.php?p=13413833#p13413833

I'm not going to create the bookmarklet for you.

Bananasik
 
Posts: 12
Joined: November 7th, 2016, 3:10 am

Post Posted February 10th, 2019, 2:30 am

It's a pity. Unfortunately my knowledge is not enough to convert these scripts to a working bookmarklet myself, but thanks anyway.

WildcatRay

User avatar
 
Posts: 7472
Joined: October 18th, 2007, 7:03 pm
Location: Columbus, OH

Post Posted February 10th, 2019, 5:23 am

Isn't is as simple as copy and paste?
Ray

OS'es: 4 computers with Win10 Pro 64-bit; Current Firefox, Beta, Nightly, Chrome, Vivaldi

Bananasik
 
Posts: 12
Joined: November 7th, 2016, 3:10 am

Post Posted February 10th, 2019, 5:59 am

if only it was that easy. Those scripts were designed to work with built in into a web page button, so simple copy and paste will not work. Already tried that.
And i can't edit them and make compatible with bookmarklet execution, due to the lack of knowledge :( It’s simple for those who know JS and almost impossible for those who don’t.

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 1 guest