You are not logged in.

#1 2014-08-09 04:35:12

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 12,935

Arch Forum Hacks for Chromium

I confess;  I like chromium.  It has some annoying behavior when using these forums, and as I spend a fair amount of time here, I found myself being frustrated often.  I do not like recent incarnations of Firefox.  Hence, I decided to fix my annoyances with Chromium.

Chrome, unlike every other browser I have used on these forums does not update the new/old status of items in the various sub-forums and search functions when you use the back function to return to the page.  If I look for my posts, click on the first one that is marked new, read the posts, then hit back; the results page still shows what I had just read as unread.  Firefox and others update the status as I expect.

To remedy this, I wrote a simple browser extension.  Below are the files one needs.  I am not ready to create a packed extension as yet, and I want to provide my source.  To use these, you need to use the developer mode of Chromium to load unpacked extensions.  See the Chromium Extension Developer docs.

manifest.json

{
    "manifest_version": 2,
    
    "name": "Arch Linux Forums Fixes",
    "description": "This extension fixes weirdness in Arch Linux Forums.",
    "version": "1.0",
    "permissions": [
	"https://bbs.archlinux.org/",
	"tabs"
    ],
    "background" : {
	"scripts": ["background.js"]},
    "page_action": {
	"default_icon": "icon.png",
	"default_popup": "popup.html"
    },
    "content_scripts": 
    [
        {
            "matches":["https://bbs.archlinux.org/*"],
            "js":["jquery-min.js","action.js"],
	    "run_at": "document_start"
        }
    ]
    
}

action.js

var myclass = new RegExp('\\binew\\b');
var elem = document.getElementsByTagName('*');

// If there are any elements taged as inew, they may be stale.  If one is found, 
// refresh the part of the page that contains the results using Ajax

chrome.extension.onMessage.addListener(function(msg, sender, sendResponse) {
    if (msg.action == 'check_for_reload') {
	for (var i = 0; i < elem.length; i++) {
	    var classes = elem[i].className;
	    if (myclass.test(classes)) 
	    {
		// jQuery load used this way was giving me duplicate tags.  Unwrap the new one after we are done
		$("#brdmain").load(location.href+" #brdmain", function () {
		    $(this).children().unwrap() });// remove the second brdmain from the DOM completely
		// once we find one inew, no need to keep looking
		break;
	    }
	}
	
    }
});

popup.html

<!doctype html>
<html>
  <head>
    <title>Arch Forums Hacks</title>
    <style>
      body {
        min-width: 357px;
        overflow-x: hidden;
      }

      img {
        margin: 5px;
        border: 2px solid black;
        vertical-align: middle;
        width: 75px;
        height: 75px;
      }
    </style>

    <!-- JavaScript and HTML must be in separate files -->
    <script src="popup.js"></script>
  </head>
  <body>
<div id=fixme>This space intentially left blank></div>  
</body>

popup.js

document.addEventListener('DOMContentLoaded', function () {
  document.getElementById("fixme").innerHTML = "<u>Arch Linux Forus Hacks</u><p>Someday I'll do something useful in this space.  Maybe controls for BBCode or something like that.<p>For now, I have focused on making the back button work as I expect.<p>>ewaller";
});

You also need an arch icon called icon.png, and jQuery (min) in a file called jQuery-min.js


Edit:  Here is a link to a tar file https://dl.dropboxusercontent.com/u/103 … hForum.tar
It should be possible to unpack this, put chromium into developer mode, and install the extension by pointing chromium's unpacked extension search at the directory archForum

Last edited by ewaller (2014-08-09 04:47:53)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Like you, I have no idea what you are doing, but I am pretty sure it is wrong...Jasonwryan
----
How to Ask Questions the Smart Way

Offline

#2 2014-08-09 09:35:20

karol
Archivist
Registered: 2009-05-06
Posts: 25,428

Re: Arch Forum Hacks for Chromium

It's webkit's fault, but IIRC it should have been already fixed.
https://github.com/WebKit/webkit/blob/m … nks-2.html

Offline

#3 2014-08-09 11:32:44

Rasi
Member
From: Germany
Registered: 2007-08-14
Posts: 1,844
Website

Re: Arch Forum Hacks for Chromium

too bad chromium does not use webkit


He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams

Offline

#4 2014-08-09 22:41:02

karol
Archivist
Registered: 2009-05-06
Posts: 25,428

Re: Arch Forum Hacks for Chromium

Maybe they want to make Blink bug-compatible with webkit?
<shrugs>

Offline

Board footer

Powered by FluxBB