I'm proud to announce my first chrome extension!

For all coding issues - MODers and programmers, HTML and more.

Moderators: Jeff250, fliptw

Post Reply
User avatar
Isaac
DBB Artist
DBB Artist
Posts: 7127
Joined: Mon Aug 01, 2005 8:47 am
Location: Ơ̸̦͇̲̬̭̱̰͎̞͈̣͎͚̳ͬ͋̃̀̇͊͂͋͐ͦ̽ͣ̂ͥ͊̅̀̚͠ B̶͖̯͉̜̰̲̓̔͋̈́ͅ È̯ Y̪̤̼͉̠̙͝

I'm proud to announce my first chrome extension!

Post by Isaac » Thu Sep 25, 2014 5:19 pm

What's it do? Temporarily disable javascript on a page you're going enter, by right clicking and selecting an option to open the link without javascript allowed on that page. If you realize you want javascript, close the tab and open the link again and javascript will return!

https://chrome.google.com/webstore/deta ... iccfohbnmh

Here's all the source code that runs it:

manifest.json

Code: Select all

{ "manifest_version": 2, "name": "Right-click no actions", "description": "Right click any URL to open it without javascript. Close the tab and reopen to undo effect", "version": "1.5.1", "permissions": [ "contextMenus", "tabs", "contentSettings" ], "background": { "scripts": ["noaction.js"] } }

Javascript:

Code: Select all


	var link=""
	var pattern=""

function linkOnClick(info, tab) {
	r = /:\/\/(.[^/]+)/;
	link=info.linkUrl
	pattern="http://"+link.match(r)[1]+"/*"

	chrome.contentSettings.javascript.set(
		{'primaryPattern':pattern,
		'setting': "block",
		'scope':'regular'},
		function(){
			window.open(link)
			chrome.contentSettings.javascript.set({
			'primaryPattern':pattern,
			'setting': "allow",
			'scope':'regular'
			})
		});
	}

	chrome.contextMenus.create({title: "Load with no Javascript", contexts:["link"], onclick: linkOnClick});
Works like a charm!
s☼-£♦и̫͍ͥ̍ͪ͌̓͗͡о̡̹̱͊̅ͮ̓̕͢б̧̝̻̪̤̳̜͐̓̉ͤ͢͜ ͙̬͙̆̑ͮ̐ͭ̾̂́͘i̎̌̾̓̽̀̈̓̀҉͉̙̦͎̘̝͕f̻͕͔̘ͣͣ̓͊̿͢͜ ͍͔͈͕̮̫ͣ̆ͮ̊͋/♂6Æ!♪╩"▲L└уͭ̂͐̇҉̴̣̼̞̠̯͓̺̞ф̜̊͌̈́̋̏̐́ц̨͔̮̿̇ ̨̛͖̙͖̖̮̗̱ͩ̆͞ͅа̥͇̞̖͚̟̅͐ͤ͞͠͠э̜̘̩̳̬͔̾ͯ̀ͫ̒̐̿ͅͅг̭̖̀ͦ̒̑ͥ̌ͮͫ͞ё͔̟̃ͬ̾̓͟ё̦̞̙̫͔̩͑̀͂ͯ̄̔̃̑̀͠ͅͅ
Post Reply