In the Name of Accessibility: Check Your Alt Attributes!

Occasionally I am browsing the net with images switched off because I am only interested in the text and don’t want to download gigantic amounts of decorative images – especially since several pages started to use HDPI images which are 4 times the size needed and thus HUGE downloads – and I noticed that seemingly some authors are not aware that they are missing an important accessibility feature, that exists since about the web was invented:

The alt attribute on images.

While people who don’t switch off image loading or can see well and don’t need to use assistive technologies like e.g. screen readers to get hold of the content, users who don’t or can’t display images for various reasons are at loss in such a situation, so please, dear web developers, check if all of your non-decorative images have those alt attributes.

An easy way is to temporarily overwrite the page styles with the following stylesheet:

html::before {
    content: "All visible images are either missing alt attributes or the alt attributes don't follow the specification!" !important;
    font-family: sans-serif !important;
    font-size: 20px !important;
    font-weight: bold !important;
    text-align: center !important;
    color: #F8F8F8 !important;
    background-color: #EE3333 !important;
    padding: 5px 0 !important;
    margin: 0 !important;
    border: none !important;
    width: 100% !important;
    float: none !important;
    position: static !important;
    display: inline-block !important;
}
html {
    color: #202020 !important;
    background-color: #F8F8F8 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    width: auto !important;
    max-width: none !important;
    display: block !important;
}
html * {
    visibility: hidden !important;
}
html area,
html img {
    visibility: visible !important;
}
html area[alt],
html img[alt] {
    visibility: hidden !important;
}
html area[alt="*"],
html area[alt=""],
html img[alt="*"],
html img[alt=""],
html img[alt^=" "] {
    outline: 4px solid rgb(51, 102, 204) !important;
    visibility: visible !important;
}

You might need to adapt it if you use a Styling Extension, this is written for direct use in Vivaldi.

In Vivaldi you can add this as page action. Just save it as Image_Alt_Debugger.css to [path to]\Application\#.#.###.##\resources\vivaldi\user_files and after the next browser restart you will see the Entry “Image Alt Debugger” in the list of page actions. (Hint: Underscores in the name get replaced by Spaces for display)

HTH 🙂

PS: Sadly you have to do that for each and every update of Vivaldi because or some unknown reason they put this stuff into the Application directory instead of the User Data directory.

Why Vivaldi’s Reader (and others) sometimes don’t do what you expect

TL;DR

Vivaldi Read Mode was was never meant for pages like Twitter, Youtube comments, or Facebook chats but for articles

As general rule of thumb you can assume that everything that has a continuous or adjacent text chunk of more than 300 characters counts as content. It may be split in multiple adjacent paragraphs, but must look content-y enough (i.e. consist of sentences) and may not contain too many links, videos or images inside of the content area (outside is fine) and does not belong to one of the “stop” classes and IDs like e.g. “comment”, “footer”, “ad”-vertisement and many others.

/TL;DR

Still there?

History

The Vivaldi Read View is – like the read view in Mozilla Firefox and the Apple Safari – based on the Readability(TM) code that was released as a labs experiment by arc90 in about 2009 under an open source license (some versions under MIT, some under Apache license). Later arc90 changed it to a server supported version that is available at readability.com

The Intention Behind It

Readability was never meant to be an ad-blocker, but always as a on-demand reader view to switch on for *articles*, meaning: Longer passages of text (important!)

It was never intended to be used on pages like Facebook, with its gazillions of short text snippets, Youtube video comments, Twitter feeds and generally not on any page that does not contain a sizable longer chunk of text in one article.

It was meant to make reading of longer texts distraction free by removing e.g. advertisements, page navigation, comments and videos or images that don’t belong to the main article content, and to re-style it with readable fonts and colors to make reading more pleasurable. 

How?!

Of course the code is not really “intelligent” (it has to be fast and may not use up too many resources), so it has to trust on some kind of heuristics to detect where the main content might be. While generally it works quite well, it may fail on some pages, especially “if the HTML is totally hosed” (not my words, that was a comment of one of the original arc90 developers)

A (simplified and not complete) Explanation:

First steps:

  • Remove all scripts.
  • Remove all styles.
  • Ignore HTML block level elements like paragraphs and divisions with less than 25 characters completely.
  • Remove HTML block level elements that have “stop” classes or IDs or tags that indicate that they are definitely not content but something else like e.g navigation, footers, comments or advertisements etc.pp.

After that the reader loops through all paragraphs, and

  • calculates the over-all score for text length by the following formula: 
    rounded-down((pure-Text character count of a page element)/100)
    and adds it to the parent element (you might see it as a container). This means: A paragraph with less than 100 characters of text does not get any bonus at all.
  • adds a base score of 1 for each remaining paragraph to the parent element 
  • assigns a score to them based on how content-y they look. This score gets added to their parent node.
  • adds additional scores that are is determined by things like number of commas (+), class names and IDs (+/-), image and link density (More than 25% of the text is links? Too many images per paragraph? Punish it!) etc.
  • punishes List, Headline, Forms and Address and some other Elements with negative scores because they are normally not part of articles, and if they are, they are usually in the same parent container as the paragraphs in a real article, so the combined score of the parent element is still high enough to count.
  • adds half of the resulting score to the grandparent elements.

When that all is done and the parent or grandparent has a high enough score, it is seen as content and gets displayed, everything else gets removed.

Probably you can imagine now, how many pitfalls are there in which content detection may fall, so please take a break if you see it fail and think about what might have caused it this time.

Personal side note (strong language warning)

All in all content detection is a bіtch and can definitely fail on some pages, especially if the “Webmasters” (I call them Crapmasters) don’t know what a HTML validator is and have never heard about structured pages and accessibility. I am speaking out of experience: Back in 2009 I started with a userscript and later made an made an extension (cleanPages, see the old my.opera page on archive org) based the full original arc90 code and fine tuned it for Opera Presto (and ported it later for the new Opera thing). It had over 250k installs and while it was fun to tweak for better results, it was a hell of a lot of work. I wrote more than 200 versions with generic fixes for “just another couple of new pages that fail” but in the end I gave in and called it a day  – there are too many broken pages out there where the webmasters seemingly do not want people to read the content. Their wish is my command 😉

So please be gentle with the Vivaldi developers – yes, there is still some fine-tuning to be done, but that is really time consuming. It will probably have to wait because there are some other, more difficult and bigger things in the pipe (hint, hint 😀 )

Thank You!

Disclaimer: While I am a “Soprano” (aka external tester for internal builds), all the views in this text are my private views and do not necessarily reflect the views or opinions of Vivaldi (the company) or any of it’s owners or employees.

Always ask for the download location (hack)

Deprecated – is now built in.

Several users, one of them me, prefer Vivaldi to ask for the download location for every download. Sadly unchecking the option Settings > Downloads: “always save to default download location” does not work for some types of downloads, especially downloads with generated files or downloads initiated with Javascript.

It is possible to do that with a little hack, but it comes with a caveat:

It breaks the “open” button behavior of the download dialog – so you have to open it manually after download.

 

Having said that, here it is:

  • look for the user profile directory of your Vivaldi in vivaldi://about  (V-Button > Help > About) and open that in your file manager.
  • close Vivaldi
  • open the file named preferences with a decent editor (You should backup that file before, just in case, you know …)
  • search for:
    "download":{
    (including the quotation marks etc.)
  • look for the } that follows immediately after that
  • before the } add the following:
    ,"prompt_for_download":true
    (including the comma and the quotation marks etc.)
  • Save the file.

 

Done. From now on Vivaldi should ask before every download – but be aware of the caveat!

 

 

 

How to get the data of the SmartRSS Extension from Opera 15++ to Vivaldi

Open Vivaldi and Opera 15+

 

In Vivaldi:

  • go to https://addons.opera.com/en/extensions/details/smart-rss/?display=en 
  • click “Add to Opera” 
  • on the popup thingy click on “get it anyway”
  • save to a place where you can find it again. 
  • open vivaldi://plugins
  • drag and drop the extension file from your file manager to the vivaldi://plugins tab

 

In Opera 15+:

  • right click on the extension’s button
  • on the popup click “Options”
  • in the options tab click on one of the “Export” buttons. I personally prefer “smart” because I want the contents of the feeds too, otherwise OPML, which works for some other readers too  
  • click on the new link that shows after you pressed the export button
  • save it in a location where you can find it again

You can close Opera now.

 

In Vivaldi:

  • open the smart RSS tab by clicking on the extension’s icon
  • click on the wrench icon
  • in the popup click on “Options”
  • in the options tab click on appropriate the import button (depending to which format you exported)
  • select previously exported file
  • wait until the import is finished successfully (there is some status information showing next to the button)

 

After those steps all feeds should be imported to Vivaldi.

 

HTH 🙂

Followup on styling Vivaldi with CSS

Outdated. No longer needed! We have Themes now 🙂

Following up the post https://quhno.vivaldi.net/2015/07/02/some-quick-vivaldi-panels-css-hacks-for-better-readability-or-accessibility/

I’ve made some smallish changes that take care of some minor things I don’t like with the UI. They can be applied the same way as in the previous blog post.

This time I move the notes editor scrollbar to the right, make the speed dial navigation a little bit less high so that it aligns with the header of the web-panels, moved the speed dial items a bit upwards and colored the panel scrollbars for the dark UI.

Extrensions are great – Extensions inhibit progress

Sounds provocative?
Fine. It was planned to sound like that.

While we all go conform that it is impossible to cover every  need of a user with one software alone and that we therefore need a way to extend it, sometimes extensions can be a blocking stone for other development.
Continue reading “Extrensions are great – Extensions inhibit progress”

Broken CSS? Lint it!

While looking for something completely different I stumbled upon CSS LINT.

Quote:

Will hurt your feelings*

(And help you code better)

http://csslint.net/

Not the usual beautifier but does what it says: It tells you what you can and should improve in a similar rigorous way as JSLint does for JavaScript. Be prepared for a long list of Errors or Warnings 😉

 

While it did not hurt my feelings (Sticks and stones …) it gave me several valuable hints how to improve my CSS-Fu …

Restoring the Old Opera 12 Space Bar Behavior in Vivaldi

In the good old days of “The Real Opera(TM)” there was one feature for lazy people like me that I heavily used: The Space Bar!

I can hear you saying “The space bar is no feature, it is a key on the keyboard!” but that is only half of the truth:

If no edit field was focused but the page itself and you pressed the space bar, “The Real Opera(TM)” scrolled one page down. Nothing special so far, almost all browsers today do that (guess from which browser they copied that function ;)) but the other browsers missed one thing:

If you were on a paginated page or if the page had a LINK or an A rеl="neхt" element, or if simply the linktext contained “Next” or something similar in one of many languages,”The Real Opera(TM)” took you to the next page after you had scrolled to the bottom and hit the space bar again. I am one of those persons who actually read pages until the bottom and often follow the link to the next part of the article, so trying to restore this behavior was a must.

OK. Stop babbling and show us the code instead!

// ==UserScript== 
// @name Restore O12 space bar behavior
// @version 0.19 
// @author Roland "QuHno" Reck 
// @include http://*.* 
// @include https://*.* 
// ==/UserScript== 
(function (window) {
  "use strict";
  /*jshint browser: true, devel: false, debug: true, evil: true, forin: true, undef: true, bitwise: true, eqnull: true, noarg: true, noempty: true, eqeqeq: true, boss: true, loopfunc: true, laxbreak: true, strict: true, curly: true, nonew: true */
  function is_number(obj) {
    return !isNaN(obj - 0);
  }
  function make_ipattern(string) {
    return '/' + string + '/i';
  }
  function split_hash(obj) {
    //return (url + '#a').split('#')[0];
    return (obj.pathname + obj.search);
  }
  function getScrollMaxY() {
    return document.documentElement.scrollHeight - document.documentElement.clientHeight;
  }
  function scrollToPos(el, x, y) {
    el.scrollLeft = x;
    el.scrollTop = y;
  }
  var i,
  j,
  HREF = split_hash(window.location),
  PROTOCOL = window.location.protocol,
  HOST = window.location.host,
  HOSTPATTERN = make_ipattern(HOST),
  A,
  LRN,
  theParent,
  searchDepth,
  stop = false,
  linkContainer = false,
  regexps = {
    trim: /^\s+|\s+$/g,
    normalize: /\s{2,}/g,
    relLink: /^next$/gi,
    nextLink: /(Next\s*(page)?|Neste\s*(side)?|N(ä|ae)chste\s*(Seite)?|Weiter(e.*)?|Vorw(ä|ae)rts|Volg(ende)?\s*(bladsy|pagina)?|Verder|(Page)?\s*Suiv(ant)?(e)?(s)?|(Page)?\s*(prochaine)|Avanti|(Pag(ina)?)?\s*Succ(essiv(e|a|o)|Prossim(e|a|o))|Altr(a|o)|(P(á|a)gina)?\s*(S(e|i)guie?nte)|Próxim(a|os?)|Nästa\s*(sida)?|Næste?\s*(side)?|下一頁|下一页|Sonraki|Следующая|Далее| 下一页|下一张|下一篇|下一章|下一节|下一步|下一个|下页|后页|下一頁|下一張|下一節|下一個|下頁|後頁|다음|다음\s*페이지|次へ|Seuraava|Επόμενη|Следващ(а|о|и)\s*(страница|сайт)?|Нататък|След(в|н)а|(Пълен)?\s*Напред|Dalej|Następn(a|e|y)|Więcej|Tovább|Köv(etkező|\.)|Bővebben|Înaint(ar)?e(ază)?|Avansează|(Pagina\s*)?Următoa?r(e|ul)?|>([^\|]|$)|»([^\|]|$)|→)/i,
    extraneous: /print|archive|comment|discuss|e[\-]?mail|share|reply|all|login|sign|single|teaser/i,
    back: /(back|prev|earl|old|new|zurück|vorige|rückwärts|назад|<|«)/i,
    images: /\.jpe?g$|\.png$|\.webp$|\.gif$/i,
    cut: /[?#]/
  },
  actHREF,
  prevHREF,
  imageResult,
  shouldImagePreview = false,
  shouldFF = false,
  UUID = '43D82723-A99E-4BFD-ACDC-B7D8270EE75C';


  /* *********************************************************************************************
  FIND LINK TO NEXT PAGE
   */
  function analyze() {

    HREF = split_hash(window.location);
    PROTOCOL = window.location.protocol;
    HOST = window.location.host;
    HOSTPATTERN = make_ipattern(HOST);
    LRN = false;
    linkContainer = false;

    //* STEP 1: Look if the webmaster knew rel=  *//
    // If there is a <link rel="next" ... and it it points to the same origin: Use it.
    LRN = document.querySelector('link[rel="next"]');
    if (!!LRN && LRN.href.indexOf(window.location.origin) < 0) {
      LRN = false;
    }
    // If there is a <A rel="next" ... and it it points to the same origin: Use it.
    if (!LRN) {
      linkContainer = document.body.querySelector('A[rel="next"]');
      if (!!linkContainer && linkContainer.href.indexOf(window.location.origin) < 0) {
        linkContainer = false;
      }
    }

    if (!linkContainer) {

      A = document.body.querySelectorAll('A');
      for (i = 1, j = A.length - 2; i < j; [i++]) {
        // Skip this link if does not have the same origin
        if (A[i].href.indexOf(window.location.origin) < 0) {
          continue;
        }

        //* STEP 2: Try to find out if the classes and IDs of the parent elements give a hint on the next link. *//
        actHREF = split_hash(A[i]);
        prevHREF = split_hash(A[i - 1]);
        theParent = A[i];

        // We limit the search depth to 6 to avoid wading through too many elements
        searchDepth = 6;

        stop = false;
        while (searchDepth > 0 && stop === false && theParent.parentElement && theParent.parentElement !== document.body) {
          /*
          if (!theParent.parentElement) {
          // searchDepth = 0;
          break;
          }
           */

          theParent.classAndId = theParent.className + ' z ' + theParent.id;
          searchDepth = searchDepth - 1;

          // This is quite probably the wrong link.
          // May be this should be done outside of the loop because some navigations contain classes like "prev next" in the parent elements
          if (theParent.classAndId.match(regexps.back)) {
            stop = true;
            break;
          }

          // If we don't get "hard evidence" we don't want links in print or discussion things
          if (theParent.classAndId.match(regexps.extraneous)) {
            // stop = true;
            break;
          }

          // this could be the next link, if there is no better match later
          if (theParent.classAndId.match(regexps.nextLink)) {
            linkContainer = A[i];
          }
          theParent = theParent.parentElement;
        }
        //*
        // seems this hurts more than it is worth the time it saves
        if (stop) {
          continue;
        }
        // stop = false;
        //*/

        //* STEP 3: Look for numbered pagination like e.g. in forums *//
        if (is_number(A[i].textContent) && A[i].textContent > 0) {
          if (is_number(A[i - 1].textContent) === false || (A[i - 1].textContent - 0 === 0)) {
            if (is_number(A[i + 1].textContent) && A[i + 1].textContent > 0 && actHREF !== HREF && A[i].textContent !== '1') {
              linkContainer = A[i];
              continue;
            }
          }
          if (is_number(A[i - 1].textContent) && A[i - 1].textContent > 0) {

            // if the previous link is to the page where we are right now it is quite possible that this is the link to the next page
            if (prevHREF === HREF) {
              linkContainer = A[i];
              continue;

              // this is for skipped pagination where the actual page is not linked, so the link to the previous page is 2 lower than that to the next page.
            } else if ((A[i].textContent - A[i - 1].textContent - 0) === 2) {
              linkContainer = A[i];
              continue;
            }
          }
          // I don't know anymore why this was important, but it breaks somewhere if this is not in.
          if (prevHREF === HREF) {
            linkContainer = A[i];
            continue;
          }
        }

        //* STEP 4: Match IDs. Almost as good as rel, therefore: If there is a good ID, we take it and stop searching *//
        if (A[i].id) {
          if (A[i].id.match(regexps.nextLink)) {
            linkContainer = A[i];
            break;
          }
        }

        //* STEP 5: CLASSes are weaker than ID, so store but don't stop. If there is no better Link we take it. *//
        if (A[i].className) {
          if (A[i].className.match(regexps.nextLink)) {
            linkContainer = A[i];
            continue;
          }
        }

        //* STEP 6: We are down to textContent - quite weak, but better than nothing *//
        if (A[i].textContent) {
          if (A[i].textContent.replace(/\s+/g, ' ').length < 25 && A[i].textContent.match(regexps.nextLink)) {
            linkContainer = A[i];
            continue;
          }
        }

        //* STEP 7: TITLE, even weaker ... *//
        if (A[i].getAttribute("title")) {
          if (A[i].textContent.replace(/\s+/g, ' ').length < 25 && A[i].getAttribute("title").match(regexps.nextLink)) {
            linkContainer = A[i];
            continue;
          }
        }

      }

    }

    // Comment this out if you don't want a hint about the next link
    // set borders _and_ outlines because in most cases websites don't alter both at the same time
    if (!!linkContainer) {
      linkContainer.style.border = '1px solid #FF0000';
      linkContainer.style.outline = '1px solid #FFff00';
      if (!document.querySelector('a[rel="next"]')) {
        linkContainer.setAttribute('rel', 'next');
        // Experimental: Maybe the Fast Forward button reacts on that at some time in the future ... probably not.
        var evt = document.createEvent('Event');
        evt.initEvent('load', false, false);
        window.dispatchEvent(evt);
      }
    }
  }
  function doFastForward() {
    /* Hard coded exceptions for fucked up search engine pages */
    var temp = null;
    /* extra saussage for startpage.com */
    if (HOST.indexOf('startpage.com') > -1) {
      temp = document.querySelector('#nextnavbar > form > a > span.i_next');
      console.log('startpage.com fucked up');
      temp.click();
      return false;
    }

    /* Normal stuff */
    /* we've got a hard link rel */
    if (LRN && LRN.href) {
      window.location.href = LRN.href;
      return false;
    }
    if (!!linkContainer) {
      linkContainer.click();
    }
  }

  var handleKeyDown = function (e) {
    if (e.key === "PageDown" && shouldFF) {
      doFastForward();
    }
    // Don't space2next if the focus is in an editable area
    // Did I forget something?
    if (/INPUT|SELECT|TEXTAREA|CANVAS/.test(e.target.tagName) || e.target.isContentEditable || document.designMode === 'on') {
      return;
    }

    // ToDo: If there are linked imageExtensions, add the logic to show them

    // If the page is already scrolled to the bottom and the user hits space, go to the next page if a link was found.
    if (e.keyCode === 32 && shouldFF) {
      doFastForward();
    }
  };

  window.addEventListener('scroll', function (e) {

    // don't analyze if the user did not scroll to the bottom
    if (window.scrollY >= getScrollMaxY() && window.scrollY > 0) {
      analyze();
      shouldFF = true;
    } else if (window.scrollY < getScrollMaxY()) {
      console.log(shouldFF);
      shouldFF = false;
    }
  }, false);
  window.addEventListener('keydown', handleKeyDown, false);
})(window);

 

  • Copy the code into a decent text editor of your choice (Please make sure your editor is set to UTF-8 or you will get problems)
  • Save it as restoreSpaceBar.user.js (yes, with 2 dots.) to some place where you can find it again
  • Open vivaldi://extensions
  • Drag and drop that file on (in?) the page (you might need to enable the developer mode on the extensions management page before)
  • Confirm that you want to install it. That’s it.

 

Warning: It is still a work in progress and may break things.

If you have any idea how to improve it:

Feel free to leave a comment 🙂

PS: I totally forgot to put some tracking code into the monster RegExp 😀

Some quick Vivaldi Javascript hacks to add additional functions

Warning: Do not apply this code to a current version of Vivaldi. It will not work anymore because the Vivaldi code has changed!

 

As follow-up to the previous entry about Hacking the CSS, this time we add some new functions to Vivaldi. The Idea is based on the posts you can find at http://habrahabr.ru/users/23rd/topics/ (in Russian, Google translate helps if you don’t speak Russian). I changed them a bit to avoid some errors I saw in the debugging console and to make sure that they only do what they should (there were some minor glitches where unexpected things happened if you clicked in the wrong place – especially if you run the browser in UI debugging mode)

I ported 2 of the scripts:

“Click to minimize/hide the tab” which deactivates the current tab and shows the last active tab. (don’t click at the [x] – that still closes the tab ;))

“Right-click [+] button to paste and go in a new tab.

 

For testing reasons you can deactivate each of them by removing the first slash at the leading //*.

How to …?

Look in the application folder of Vivaldi for browser.html in the ressources/vivaldi folder and open it with a text editor.

Insert after the string and save it.

Create a folder in the same directory as browser.html and rename the folder to custom_ui . It should be already in the right place if you followed Method 2 in the previous entry about Hacking the CSS.

Save the following code as custom.js into the new folder:

 

(function () {     // get the whole browser UI. Do this only once!     var browser = document.body.querySelector('#browser');          // we need to emulate a click sometimes. Do this only once!     var dispatchMouseEvent = function (target, var_args) {         var e = document.createEvent("MouseEvents");         e.initEvent.apply(e, Array.prototype.slice.call(arguments, 1));         target.dispatchEvent(e);     };      /*     Single click on a tab to hide it and show the last active tab.      */ //*     var list = [];     function listTabs() {         var tabs = browser.querySelectorAll('#tabs>.tab');         list = [];         for (var i = 0; i < tabs.length; i++) {             list.push(tabs[i]);         }         list.sort(function (a, b) {             return recent(b) - recent(a);         });     }          function recent(tab) {         var page = document.querySelector('.webpageview webview[tab_id="' + tab.dataset.tabId + '"]');         if (page) {             page = page.parentNode.parentNode.parentNode.parentNode;             return parseInt(page.style.zIndex);         }         return 0;     };      function startAction(e) {         for (var i = 0; i < e.path.length; i++) {             // clicking on tab group switches should not fire, neither should clicking anywhere in the webpageview             if (e.path[i].classList && (e.path[i].classList.contains('tab-indicator') || e.path[i].classList.contains('webpageview'))) {                 break;             }             if (e.path[i].classList && e.path[i].classList.contains('active')) {                 var active = browser.querySelector('.tab.active');                 listTabs();                 dispatchMouseEvent(list[1], 'mousedown', true, true);                 break;             }         }     };          browser.addEventListener('mousedown', function (e) {         // Make sure that it fires on left mouse click only         //  e = e || window.event;         switch (e.which) {         case 1:             startAction(e);             break; // left         case 2:             break; // middle         case 3:             break; // right         }     }); //*/       /*     Right click on plus-button to paste and go      */ //*     var isItMouse = false; // Exclude responses from keyboard      //Tweak for paste in this input-field     var hiddenInput = document.createElement("input");     hiddenInput.type = "text";     browser.appendChild(hiddenInput);     hiddenInput.style.width = "0px";     hiddenInput.style.height = "0px";     hiddenInput.style.display = "none";      browser.addEventListener('contextmenu', function (e) {         // Area near square         if (e.target.className.toString().indexOf('newtab') > -1) {             isItMouse = true;             document.execCommand('paste');             return;         }         // Plus-symbol         // changed to parentElement instead of parentNode         if (e.target.parentElement.className.indexOf('newtab') > -1) {             initPaste();             return;         }         // Square         if (e.target.parentElement.parentElement.className.indexOf('newtab') > -1) {             initPaste();             return;         }     });      function initPaste() {         isItMouse = true;         hiddenInput.style.display = "block";         hiddenInput.focus();         document.execCommand('paste');     }      document.addEventListener('paste', function (e) {         if (isItMouse) {             isItMouse = false;             var url = e.clipboardData.getData('text/plain');             hiddenInput.style.display = "none"; //hide input-field for pasting              var re = new RegExp('\\r\\n', 'g'); // Delete newline characters             url = url.replace(re, '');                          // Search engines             var searchEngine = 'https://google.com/webhp?q=';             // var searchEngine = 'http://yandex.ru/search/?text=';             // var searchEngine = 'https://duckduckgo.com/?q=';             // ... or insert search string of your favorite search engine                          var active = browser.querySelector('.tab.active');             var webview = document.querySelector('#webview-container webview[tab_id="' + active.dataset.tabId + '"]');              if (url.length > 0) {                 if (checkUrl(url)) {                     webview.executeScript({                         code : "window.open('" + url + "','_blank')"                     });                 } else if (checkUrlWithoutProtocol(url)) {                     webview.executeScript({                         code : "window.open('http://" + url + "','_blank')"                     });                 } else {                     webview.executeScript({                         code : "window.open('" + searchEngine + url + "','_blank')"                     });                 }             }             //    console.log(url)         }     });          //Check url     var patternUrl = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?/#]\S*)?$/i;     var patternUrlWithout = /^(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,3})).?)(?::\d{2,5})?(?:[/?/#]\S*)?$/i;          //url with protocol     function checkUrl(str) {         return patternUrl.test(str);     }          //url without protocol     function checkUrlWithoutProtocol(str) {         return patternUrlWithout.test(str);     } //*/ })();

Some quick Vivaldi panels CSS hacks for better readability or accessibility

Deprecated. While the basic technique would still work, too much has changed in the new Versions of Vivaldi and now we have Themes.

While I generally like the design idea that stands behind behind Vivaldi, I have some problems with it. I don’t know which screens the designers use or if they are calibrated, if their eyesight is perfect or not, but the contrast of some elements in the default light and dark themes is a little bit too low for me to feel comfortable, especially in the panels. Luckily the whole UI of Vivaldi is based on web technology—or in non marketing speak: HTML, JavaScript and CSS—it is quite easy to hack.

b2ap3_thumbnail_Vivaldi-Panel-CSS-Mod_20150702-163235_1.png

Yes I resized the screenshot deliberately to a smaller size. As you can see everything in the panels stays visible, despite the smaller size . You can try that with the default interface, but don’t use sharpening while resizing 😉

The following hack does not solve all problems I see, e.g. the less than sufficient contrast of the Tab titles in the dark interface if you do not use transparent tabs, but you can see it as a first step for your own experiments.

 

How to …?

Method 1:

Look for common.css in the application folder of the browser and open it with a text editor.

Add the following to the end of it (make sure you add it at the end!)

Method 2:

Look in the application folder of Vivaldi for browser.html in the ressources/vivaldi folder and open it with a text editor.

Insert <link rel="stylesheet" href="custom_ui/panel.css" /> after the string <link rel="stylesheet" href="style/common.css" /> and save it.

Create a folder in the same directory as browser.html and rename the folder to custom_ui

Save the following code as panel.css into the new folder:

 

#switch {     background: #dfdfdf;     box-shadow: 2px 0 0 -1px rgba(255, 255, 255, .3), -2px 0 0 -1px rgba(255, 255, 255, .3); } .ui-dark #switch {     background: #333333;     box-shadow: 2px 0 0 -1px rgba(255, 255, 255, .9), -2px 0 0 -1px rgba(255, 255, 255, .9); } .ui-light #switch button svg {     fill: rgba(0, 0, 0, .7) } .ui-dark #switch button svg {     fill: rgba(255, 255, 255, .7) } .ui-dark #panel_switch {     background-color: #3f3f3f;     box-shadow: 2px 0 0 -1px rgba(0, 0, 0, .4), -2px 0 0 -1px rgba(0, 0, 0, .4); } .ui-light .panel-group {     box-shadow: 2px 0 0 -1px rgba(0, 0, 0, .2), -2px 0 0 -1px rgba(0, 0, 0, .2); } .ui-dark .panel-group {     box-shadow: 2px 0 0 -1px rgba(255, 255, 255, .2), -2px 0 0 -1px rgba(255, 255, 255, .2); } .ui-light #switch button.active {     box-shadow: inset 1px 1px 1px 0px rgba(0, 0, 0, .3); } .ui-dark #switch button.active {     background-color: #464646;     box-shadow: inset 1px 1px 1px 0px rgba(255, 255, 255, .3); } .ui-light #switch button:not(.active):hover {     background: #eeeeee; } .ui-dark #panels-container.left #panel_switch,  #panels-container.right #panel_switch.off {     background-repeat: no-repeat;     background-position: center;     background-size: contain;     /* arrow-left white */     background-image: url("data:image/svg+xml;utf8,"); } .ui-dark #panels-container.left #panel_switch.off, #panels-container.right #panel_switch {     background-repeat: no-repeat;     background-position: center;     background-size: contain;     /* arrow-right white */     background-image: url("data:image/svg+xml;utf8,"); } .ui-dark .addbookmark-cardwrapper, .ui-dark .downloaddialog-cardwrapper, .ui-dark .notes-cardwrapper {     box-shadow: inset 1px 1px 0 0px rgba(255, 255, 255, .2), 2px 2px 0px 1px rgba(0, 0, 0, .4); } /* Dark UI: Make the color of the font a bit lighter in the tab .ui-dark #tabs .tab{color:rgba(255,255,255,.6);  */  .ui-dark #tabs .tab {     color: rgba(255, 255, 255, .8);     background-color: #333; } .ui-dark #tabs .tab:hover {     color: rgba(255, 255, 255, 1);     box-shadow: inset 1px 1px 1px 0px rgba(255, 255, 255, .8); } .ui-dark #tabs .tab:not(.active):hover {     background-color: #444; }  .ui-dark #tabs .tab.unread.tab-transparent {     box-shadow: inset 0 -2px 0 0 #CCCCCC,inset 0 -4px 0 0 rgba(0,0,0,.2); }  .ui-dark  .close {     background-image: url(/resources/close-white.png); }  .ui-dark  #footer .paneltogglefooter svg {     fill: rgba(255, 255, 255, .9) }  .ui-dark #footer #status_info {     color: #ffffff; } /* Make the free space right to the tabs draggable if tab container is at top #browser:not(.mac) .tab-spacer,#tabs .tab,#zoom_control,.tab-group-indicator,.topmenu,button,input{-webkit-app-region:no-drag}  Only needed for builds lower than 1.0.230.#, see help > about */ /*  #browser:not(.mac) .top .tab-spacer{ -webkit-app-region:drag } */  .vivaldi-tree .tree-row.folder .folder-item-count {     opacity: .5;     color: rgba(0, 0, 0, 1) } .ui-dark .vivaldi-tree .tree-row.folder .folder-item-count {     opacity: .5;     color: rgba(255, 255, 255, 1) } .hasfocus .bookmark-bar button:hover img.icon {     background-color: rgba(255, 255, 255, 0);     border-color: rgba(255, 255, 255, 0); } .bookmark-bar button img.icon {     background-color: rgba(255, 255, 255, 0);     border-color: rgba(255, 255, 255, 0); } .bookmark-bar button {     border: 1px outset rgba(0, 0, 0, 0) } .hasfocus .bookmark-bar button:hover {     -webkit-filter: saturate(150%) brightness(150%); } /* a bit of blue tint ... */  .vivaldi-tree .tree-row:not([data-selected]):hover {     background-color: rgba(0, 110, 215, .4); } .ui-dark .vivaldi-tree .tree-row:not([data-selected]):hover {     background-color: rgba(0, 110, 215, .4); } .vivaldi-tree .tree-row[data-selected] , .vivaldi-tree .tree-row[data-selected]:hover{     color: #eee;     background-color: #006ed7;     border: 0 } .vivaldi-tree .tree-row[data-selected]:hover{     color: #fff; } .vivaldi-tree .tree-row[data-selected][data-nofocus] {     background-color: rgba(54, 95, 135, .2);     color: inherit;     border: 0 } .ui-dark .vivaldi-tree .tree-row[data-selected][data-nofocus] {     background-color: rgba(54, 95, 135, 1);     color: inherit;     border: 0 }  /* a bit of blue tint ... */  .ui-dark ::-webkit-scrollbar {      width: 15px;      height: 15px; } .ui-dark ::-webkit-scrollbar-button {       background-color: #333;      border: 1px solid #555; } .ui-dark ::-webkit-scrollbar-track {       background-color: #000000; } .ui-dark ::-webkit-scrollbar-track-piece {      background-color: #333333; } .ui-dark ::-webkit-scrollbar-thumb {      height: 50px;      background-color: #666; } .ui-dark ::-webkit-scrollbar-corner {      background-color: #999; } .ui-dark ::-webkit-resizer {      background-color: #666; } .ui-dark ::-webkit-scrollbar-button {     background-repeat:no-repeat;     background-position:center;     background-size: contain; } .ui-dark ::-webkit-scrollbar-button:vertical:increment {     /* arrow-down white */     background-image: url("data:image/svg+xml;utf8,"); } .ui-dark ::-webkit-scrollbar-button:vertical:decrement {     /* arrow-up white */     background-image: url("data:image/svg+xml;utf8,"); } .ui-dark ::-webkit-scrollbar-button:horizontal:increment {     /* arrow-right white */     background-image: url("data:image/svg+xml;utf8,"); } .ui-dark ::-webkit-scrollbar-button:horizontal:decrement {     /* arrow-left white */     background-image: url("data:image/svg+xml;utf8,"); }

 

edit: There is a follow up about Hacking the UI with Javascript to add functions.